Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
Merge #257
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bors[bot] and Kerollmops authored Jun 23, 2021
2 parents 41c4a5b + 98285b4 commit c38b0b8
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 24 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ version = "0.1.0"
edition = "2018"
publish = false


[dependencies]
milli = { path = "../milli" }

Expand Down
2 changes: 1 addition & 1 deletion helpers/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "helpers"
version = "0.5.1"
version = "0.6.0"
authors = ["Clément Renault <clement@meilisearch.com>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion http-ui/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "http-ui"
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>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion infos/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "infos"
version = "0.5.1"
version = "0.6.0"
authors = ["Clément Renault <clement@meilisearch.com>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion milli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "milli"
version = "0.5.1"
version = "0.6.0"
authors = ["Kerollmops <clement@meilisearch.com>"]
edition = "2018"

Expand Down
29 changes: 16 additions & 13 deletions milli/src/update/index_documents/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub struct Readers {
pub struct Store<'s, A> {
// Indexing parameters
searchable_fields: HashSet<FieldId>,
faceted_fields: HashSet<FieldId>,
filterable_fields: HashSet<FieldId>,
// Caches
word_docids: LinkedHashMap<SmallVec32<u8>, RoaringBitmap>,
word_docids_limit: usize,
Expand Down Expand Up @@ -90,7 +90,7 @@ pub struct Store<'s, A> {
impl<'s, A: AsRef<[u8]>> Store<'s, A> {
pub fn new(
searchable_fields: HashSet<FieldId>,
faceted_fields: HashSet<FieldId>,
filterable_fields: HashSet<FieldId>,
linked_hash_map_size: Option<usize>,
max_nb_chunks: Option<usize>,
max_memory: Option<usize>,
Expand Down Expand Up @@ -190,7 +190,7 @@ impl<'s, A: AsRef<[u8]>> Store<'s, A> {
Ok(Store {
// Indexing parameters.
searchable_fields,
faceted_fields,
filterable_fields,
// Caches
word_docids: LinkedHashMap::with_capacity(linked_hash_map_size),
field_id_word_count_docids: HashMap::new(),
Expand Down Expand Up @@ -668,20 +668,23 @@ impl<'s, A: AsRef<[u8]>> Store<'s, A> {
}

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 =
serde_json::from_slice(content).map_err(InternalError::SerdeJson)?;

let (facet_numbers, facet_strings) = extract_facet_values(&value);
facet_numbers_values
.entry(attr)
.or_insert_with(Vec::new)
.extend(facet_numbers);
facet_strings_values
.entry(attr)
.or_insert_with(Vec::new)
.extend(facet_strings);
if self.filterable_fields.contains(&attr) {
let (facet_numbers, facet_strings) = extract_facet_values(&value);
facet_numbers_values
.entry(attr)
.or_insert_with(Vec::new)
.extend(facet_numbers);
facet_strings_values
.entry(attr)
.or_insert_with(Vec::new)
.extend(facet_strings);
}

if self.searchable_fields.contains(&attr) {
let content = match json_to_string(&value) {
Expand Down
2 changes: 1 addition & 1 deletion search/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "search"
version = "0.5.1"
version = "0.6.0"
authors = ["Clément Renault <clement@meilisearch.com>"]
edition = "2018"

Expand Down

0 comments on commit c38b0b8

Please sign in to comment.