mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-02-07 19:36:26 +08:00
Use the disableOnWords parameter on the facet-search route
This commit is contained in:
parent
7bd67543dd
commit
2ceb781c73
@ -294,15 +294,30 @@ impl<'a> SearchForFacetValues<'a> {
|
|||||||
match self.query.as_ref() {
|
match self.query.as_ref() {
|
||||||
Some(query) => {
|
Some(query) => {
|
||||||
if self.search_query.index.authorize_typos(rtxn)? {
|
if self.search_query.index.authorize_typos(rtxn)? {
|
||||||
|
let mut result = vec![];
|
||||||
|
|
||||||
|
let exact_words_fst = self.search_query.index.exact_words(rtxn)?;
|
||||||
|
if exact_words_fst.map_or(false, |fst| fst.contains(query)) {
|
||||||
|
let key =
|
||||||
|
FacetGroupKey { field_id: fid, level: 0, left_bound: query.as_ref() };
|
||||||
|
if let Some(FacetGroupValue { bitmap, .. }) =
|
||||||
|
index.facet_id_string_docids.get(rtxn, &key)?
|
||||||
|
{
|
||||||
|
let count = search_candidates.intersection_len(&bitmap);
|
||||||
|
if count != 0 {
|
||||||
|
result.push(FacetValueHit { value: query.to_string(), count });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
let is_prefix = true;
|
let is_prefix = true;
|
||||||
let starts = StartsWith(Str::new(get_first(query)));
|
let starts = StartsWith(Str::new(get_first(query)));
|
||||||
let first = Intersection(build_dfa(query, 1, is_prefix), Complement(&starts));
|
let first =
|
||||||
|
Intersection(build_dfa(query, 1, is_prefix), Complement(&starts));
|
||||||
let second_dfa = build_dfa(query, 2, is_prefix);
|
let second_dfa = build_dfa(query, 2, is_prefix);
|
||||||
let second = Intersection(&second_dfa, &starts);
|
let second = Intersection(&second_dfa, &starts);
|
||||||
let automaton = Union(first, &second);
|
let automaton = Union(first, &second);
|
||||||
|
|
||||||
let mut stream = fst.search(automaton).into_stream();
|
let mut stream = fst.search(automaton).into_stream();
|
||||||
let mut result = vec![];
|
|
||||||
let mut length = 0;
|
let mut length = 0;
|
||||||
while let Some(facet_value) = stream.next() {
|
while let Some(facet_value) = stream.next() {
|
||||||
let value = std::str::from_utf8(facet_value)?;
|
let value = std::str::from_utf8(facet_value)?;
|
||||||
@ -325,6 +340,7 @@ impl<'a> SearchForFacetValues<'a> {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(result)
|
Ok(result)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user