257: Fix unconditional facet indexing r=Kerollmops a=Kerollmops

We were indexing every searchable field as filterable, this was a mistake.

Co-authored-by: Kerollmops <clement@meilisearch.com>
This commit is contained in:
bors[bot] 2021-06-23 15:32:46 +00:00 committed by GitHub
commit c38b0b883d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 26 additions and 24 deletions

10
Cargo.lock generated
View File

@ -901,7 +901,7 @@ dependencies = [
[[package]] [[package]]
name = "helpers" name = "helpers"
version = "0.5.1" version = "0.6.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"byte-unit", "byte-unit",
@ -955,7 +955,7 @@ dependencies = [
[[package]] [[package]]
name = "http-ui" name = "http-ui"
version = "0.5.1" version = "0.6.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"askama", "askama",
@ -1098,7 +1098,7 @@ dependencies = [
[[package]] [[package]]
name = "infos" name = "infos"
version = "0.5.1" version = "0.6.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"byte-unit", "byte-unit",
@ -1377,7 +1377,7 @@ dependencies = [
[[package]] [[package]]
name = "milli" name = "milli"
version = "0.5.1" version = "0.6.0"
dependencies = [ dependencies = [
"big_s", "big_s",
"bstr", "bstr",
@ -2232,7 +2232,7 @@ dependencies = [
[[package]] [[package]]
name = "search" name = "search"
version = "0.5.1" version = "0.6.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"byte-unit", "byte-unit",

View File

@ -4,7 +4,6 @@ version = "0.1.0"
edition = "2018" edition = "2018"
publish = false publish = false
[dependencies] [dependencies]
milli = { path = "../milli" } milli = { path = "../milli" }

View File

@ -1,6 +1,6 @@
[package] [package]
name = "helpers" name = "helpers"
version = "0.5.1" version = "0.6.0"
authors = ["Clément Renault <clement@meilisearch.com>"] authors = ["Clément Renault <clement@meilisearch.com>"]
edition = "2018" edition = "2018"

View File

@ -1,7 +1,7 @@
[package] [package]
name = "http-ui" name = "http-ui"
description = "The HTTP user interface of the milli search engine" description = "The HTTP user interface of the milli search engine"
version = "0.5.1" version = "0.6.0"
authors = ["Clément Renault <clement@meilisearch.com>"] authors = ["Clément Renault <clement@meilisearch.com>"]
edition = "2018" edition = "2018"

View File

@ -1,6 +1,6 @@
[package] [package]
name = "infos" name = "infos"
version = "0.5.1" version = "0.6.0"
authors = ["Clément Renault <clement@meilisearch.com>"] authors = ["Clément Renault <clement@meilisearch.com>"]
edition = "2018" edition = "2018"

View File

@ -1,6 +1,6 @@
[package] [package]
name = "milli" name = "milli"
version = "0.5.1" version = "0.6.0"
authors = ["Kerollmops <clement@meilisearch.com>"] authors = ["Kerollmops <clement@meilisearch.com>"]
edition = "2018" edition = "2018"

View File

@ -55,7 +55,7 @@ pub struct Readers {
pub struct Store<'s, A> { pub struct Store<'s, A> {
// Indexing parameters // Indexing parameters
searchable_fields: HashSet<FieldId>, searchable_fields: HashSet<FieldId>,
faceted_fields: HashSet<FieldId>, filterable_fields: HashSet<FieldId>,
// Caches // Caches
word_docids: LinkedHashMap<SmallVec32<u8>, RoaringBitmap>, word_docids: LinkedHashMap<SmallVec32<u8>, RoaringBitmap>,
word_docids_limit: usize, word_docids_limit: usize,
@ -90,7 +90,7 @@ pub struct Store<'s, A> {
impl<'s, A: AsRef<[u8]>> Store<'s, A> { impl<'s, A: AsRef<[u8]>> Store<'s, A> {
pub fn new( pub fn new(
searchable_fields: HashSet<FieldId>, searchable_fields: HashSet<FieldId>,
faceted_fields: HashSet<FieldId>, filterable_fields: HashSet<FieldId>,
linked_hash_map_size: Option<usize>, linked_hash_map_size: Option<usize>,
max_nb_chunks: Option<usize>, max_nb_chunks: Option<usize>,
max_memory: Option<usize>, max_memory: Option<usize>,
@ -190,7 +190,7 @@ impl<'s, A: AsRef<[u8]>> Store<'s, A> {
Ok(Store { Ok(Store {
// Indexing parameters. // Indexing parameters.
searchable_fields, searchable_fields,
faceted_fields, filterable_fields,
// Caches // Caches
word_docids: LinkedHashMap::with_capacity(linked_hash_map_size), word_docids: LinkedHashMap::with_capacity(linked_hash_map_size),
field_id_word_count_docids: HashMap::new(), field_id_word_count_docids: HashMap::new(),
@ -668,20 +668,23 @@ impl<'s, A: AsRef<[u8]>> Store<'s, A> {
} }
for (attr, content) in document.iter() { for (attr, content) in document.iter() {
if self.faceted_fields.contains(&attr) || self.searchable_fields.contains(&attr) if self.filterable_fields.contains(&attr)
|| self.searchable_fields.contains(&attr)
{ {
let value = let value =
serde_json::from_slice(content).map_err(InternalError::SerdeJson)?; serde_json::from_slice(content).map_err(InternalError::SerdeJson)?;
let (facet_numbers, facet_strings) = extract_facet_values(&value); if self.filterable_fields.contains(&attr) {
facet_numbers_values let (facet_numbers, facet_strings) = extract_facet_values(&value);
.entry(attr) facet_numbers_values
.or_insert_with(Vec::new) .entry(attr)
.extend(facet_numbers); .or_insert_with(Vec::new)
facet_strings_values .extend(facet_numbers);
.entry(attr) facet_strings_values
.or_insert_with(Vec::new) .entry(attr)
.extend(facet_strings); .or_insert_with(Vec::new)
.extend(facet_strings);
}
if self.searchable_fields.contains(&attr) { if self.searchable_fields.contains(&attr) {
let content = match json_to_string(&value) { let content = match json_to_string(&value) {

View File

@ -1,6 +1,6 @@
[package] [package]
name = "search" name = "search"
version = "0.5.1" version = "0.6.0"
authors = ["Clément Renault <clement@meilisearch.com>"] authors = ["Clément Renault <clement@meilisearch.com>"]
edition = "2018" edition = "2018"