mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-30 00:34:26 +01:00
Merge pull request #224 from meilisearch/improve-automaton-producer
Improve the automaton producer
This commit is contained in:
commit
0ff73039e5
@ -285,6 +285,13 @@ fn search_command(command: SearchCommand, database: Database) -> Result<(), Box<
|
|||||||
Ok(query) => {
|
Ok(query) => {
|
||||||
let start_total = Instant::now();
|
let start_total = Instant::now();
|
||||||
|
|
||||||
|
let builder = index.query_builder();
|
||||||
|
let builder = if let Some(timeout) = command.fetch_timeout_ms {
|
||||||
|
builder.with_fetch_timeout(Duration::from_millis(timeout))
|
||||||
|
} else {
|
||||||
|
builder
|
||||||
|
};
|
||||||
|
|
||||||
let documents = match command.filter {
|
let documents = match command.filter {
|
||||||
Some(ref filter) => {
|
Some(ref filter) => {
|
||||||
let filter = filter.as_str();
|
let filter = filter.as_str();
|
||||||
@ -296,15 +303,14 @@ fn search_command(command: SearchCommand, database: Database) -> Result<(), Box<
|
|||||||
|
|
||||||
let attr = schema.attribute(&filter).expect("Could not find filtered attribute");
|
let attr = schema.attribute(&filter).expect("Could not find filtered attribute");
|
||||||
|
|
||||||
let builder = index.query_builder();
|
|
||||||
let builder = builder.with_filter(|document_id| {
|
let builder = builder.with_filter(|document_id| {
|
||||||
let string: String = index.document_attribute(&reader, document_id, attr).unwrap().unwrap();
|
let string: String = index.document_attribute(&reader, document_id, attr).unwrap().unwrap();
|
||||||
(string == "true") == positive
|
(string == "true") == positive
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.query(&reader, &query, 0..command.number_results)?
|
builder.query(&reader, &query, 0..command.number_results)?
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
let builder = index.query_builder();
|
|
||||||
builder.query(&reader, &query, 0..command.number_results)?
|
builder.query(&reader, &query, 0..command.number_results)?
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -210,9 +210,9 @@ fn generate_automatons(
|
|||||||
|
|
||||||
// order automatons, the most important first,
|
// order automatons, the most important first,
|
||||||
// we keep the original automatons at the front.
|
// we keep the original automatons at the front.
|
||||||
automatons[1..].sort_unstable_by_key(|a| {
|
automatons[1..].sort_by_key(|a| {
|
||||||
let a = a.first().unwrap();
|
let a = a.first().unwrap();
|
||||||
(Reverse(a.is_exact), Reverse(a.ngram))
|
(Reverse(a.is_exact), a.ngram)
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok((automatons, enhancer_builder.build()))
|
Ok((automatons, enhancer_builder.build()))
|
||||||
|
Loading…
Reference in New Issue
Block a user