-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Facet filters #631
Facet filters #631
Conversation
93ba8dd
to
5cbadb4
Compare
c7dc5ae
to
22e50fe
Compare
5cbadb4
to
99866ba
Compare
22e50fe
to
4b5f82d
Compare
2fb9d11
to
1ff80c8
Compare
will do remaining facet count in another PR ;) |
let facet_map = facets::facet_map_from_docids(writer, &index, &documents_ids_to_reindex, &attributes_for_facetting)?; | ||
index.facets.add(writer, facet_map)?; | ||
} | ||
// ^-- merge? --v |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What this comment means again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what facet map does could be done inside the loop under the comment, and save us a few db reads. this would be done at the price of less readability, and would make it harder to move this logic out if we wanted it. This comment sole purpose is to tell us that this optimization is possible, is we want it, as it is not trivial.
don't merge ! |
regarding document reindexation (meilisearch-core/src/update/documents_addition.rs:250), what facet map does could be done inside the loop under the comment, and save us a few db reads. this would be done at the price of less readability, and would make it harder to move this logic out if we wanted it. This comment sole purpose is to tell us that this optimization is possible, is we want it, as it is not trivial. |
meilisearch-core/src/facets.rs
Outdated
v => v.to_string(), | ||
// ignore null | ||
Value::Null => return Ok(()), | ||
_ => return Err(FacetError::InvalidDocumentAttribute(document_id)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be great if you show the invalid field and the fact that we only support strings and arrays of strings only.
meilisearch-core/src/facets.rs
Outdated
bad_value => { | ||
return Err(FacetError::UnexpectedToken { expected: &["String"], found: bad_value.to_string() }) | ||
} | ||
} | ||
} | ||
filter.push(Either::Left(inner)); | ||
} | ||
bad_value => return Err(FacetError::UnexpectedToken { expected: &["String", "Array"], found: bad_value.to_string() }), | ||
} | ||
} | ||
return Ok(Self(filter)); | ||
} | ||
bad_value => Err(FacetError::UnexpectedToken { expected: &["Array"], found: bad_value.to_string() }), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you create a contructor for the unexpected token, this will reduce the amount of code here.
meilisearch-core/src/error.rs
Outdated
pub fn unexpected_token(expected: &'static [&'static str], found: String) -> FacetError { | ||
FacetError::UnexpectedToken{ expected, found } | ||
} | ||
|
||
pub fn attribute_not_set(expected: Vec<String>, found: String) -> FacetError { | ||
FacetError::AttributeNotSet{ expected, found } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can reduce the line length of the other file by avoiding calling to_string
and transform it there.
pub fn unexpected_token(expected: &'static [&'static str], found: String) -> FacetError { | |
FacetError::UnexpectedToken{ expected, found } | |
} | |
pub fn attribute_not_set(expected: Vec<String>, found: String) -> FacetError { | |
FacetError::AttributeNotSet{ expected, found } | |
} | |
pub fn unexpected_token(expected: &'static [&'static str], found: impl ToString) -> FacetError { | |
FacetError::UnexpectedToken{ expected, found: found.to_string() } | |
} | |
pub fn attribute_not_set(expected: Vec<String>, found: impl ToString) -> FacetError { | |
FacetError::AttributeNotSet{ expected, foundL found.to_string() } | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good now, I would like you to rebase and I will merge :)
8c86b6c
to
7c65d48
Compare
7c65d48
to
2f71f64
Compare
2f71f64
to
0e75aef
Compare
meilisearch-core/src/facets.rs
Outdated
} | ||
return Ok(Self(filter)); | ||
} | ||
bad_value => Err(FacetError::unexpected_token(&["String"], bad_value)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bad_value => Err(FacetError::unexpected_token(&["String"], bad_value)), | |
bad_value => Err(FacetError::unexpected_token(&["Array"], bad_value)), |
meilisearch-http/Cargo.toml
Outdated
@@ -26,6 +26,7 @@ actix-web = "2" | |||
actix-web-macros = "0.1.0" | |||
chrono = { version = "0.4.11", features = ["serde"] } | |||
crossbeam-channel = "0.4.2" | |||
either = { version = "1.5.3", features = ["serde"] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you using this dependency in meilisearch-http
?
0e75aef
to
44ae216
Compare
631: Revert "Remove Bors required test for Windows" r=Kerollmops a=curquiza Reverts meilisearch/milli#612 Because the issue does not seem to be there! Closes meilisearch/milli#614 Co-authored-by: Clémentine Urquizar - curqui <clementine@meilisearch.com>
#625