Skip to content
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

Merged
merged 6 commits into from
May 11, 2020
Merged

Facet filters #631

merged 6 commits into from
May 11, 2020

Conversation

MarinPostma
Copy link
Contributor

@MarinPostma MarinPostma changed the base branch from master to tide-to-actix-web April 23, 2020 13:00
@qdequele qdequele force-pushed the tide-to-actix-web branch 3 times, most recently from 93ba8dd to 5cbadb4 Compare April 26, 2020 18:54
@MarinPostma MarinPostma changed the base branch from tide-to-actix-web to master April 29, 2020 21:03
@MarinPostma MarinPostma force-pushed the facet-filters branch 4 times, most recently from 2fb9d11 to 1ff80c8 Compare May 5, 2020 20:31
@MarinPostma MarinPostma marked this pull request as ready for review May 5, 2020 21:13
@MarinPostma
Copy link
Contributor Author

will do remaining facet count in another PR ;)

meilisearch-core/src/facets.rs Outdated Show resolved Hide resolved
meilisearch-core/src/facets.rs Outdated Show resolved Hide resolved
meilisearch-core/src/error.rs Outdated Show resolved Hide resolved
meilisearch-core/src/facets.rs Outdated Show resolved Hide resolved
meilisearch-core/src/facets.rs Outdated Show resolved Hide resolved
meilisearch-http/src/routes/setting.rs Outdated Show resolved Hide resolved
meilisearch-schema/Cargo.toml Show resolved Hide resolved
meilisearch-schema/src/lib.rs Outdated Show resolved Hide resolved
meilisearch-http/Cargo.toml Outdated Show resolved Hide resolved
meilisearch-core/src/query_builder.rs Outdated Show resolved Hide resolved
meilisearch-core/Cargo.toml Outdated Show resolved Hide resolved
meilisearch-core/src/error.rs Outdated Show resolved Hide resolved
meilisearch-core/src/error.rs Outdated Show resolved Hide resolved
meilisearch-core/src/error.rs Outdated Show resolved Hide resolved
meilisearch-core/src/facets.rs Outdated Show resolved Hide resolved
meilisearch-core/src/store/mod.rs Outdated Show resolved Hide resolved
meilisearch-core/src/store/mod.rs Outdated Show resolved Hide resolved
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
Copy link
Member

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?

Copy link
Contributor Author

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.

meilisearch-http/src/routes/search.rs Show resolved Hide resolved
meilisearch-schema/src/lib.rs Outdated Show resolved Hide resolved
meilisearch-core/src/facets.rs Outdated Show resolved Hide resolved
meilisearch-core/src/facets.rs Show resolved Hide resolved
meilisearch-core/src/store/mod.rs Show resolved Hide resolved
@MarinPostma
Copy link
Contributor Author

don't merge !

@MarinPostma
Copy link
Contributor Author

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.

v => v.to_string(),
// ignore null
Value::Null => return Ok(()),
_ => return Err(FacetError::InvalidDocumentAttribute(document_id)),
Copy link
Member

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.

Comment on lines 63 to 74
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() }),
}
Copy link
Member

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/facets.rs Show resolved Hide resolved
Comment on lines 180 to 186
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 }
}
Copy link
Member

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.

Suggested change
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() }
}

Copy link
Member

@Kerollmops Kerollmops left a 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 :)

@MarinPostma MarinPostma force-pushed the facet-filters branch 3 times, most recently from 8c86b6c to 7c65d48 Compare May 11, 2020 13:59
}
return Ok(Self(filter));
}
bad_value => Err(FacetError::unexpected_token(&["String"], bad_value)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bad_value => Err(FacetError::unexpected_token(&["String"], bad_value)),
bad_value => Err(FacetError::unexpected_token(&["Array"], bad_value)),

@@ -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"] }
Copy link
Member

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?

@Kerollmops Kerollmops merged commit b215e9e into meilisearch:master May 11, 2020
bors bot added a commit that referenced this pull request Jan 16, 2023
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants