mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 11:57:07 +02:00
Add analytics for the negative operator
This commit is contained in:
parent
1da9e0f246
commit
34262c7a0d
5 changed files with 33 additions and 2 deletions
|
@ -11,6 +11,7 @@ struct ScoreWithRatioResult {
|
|||
candidates: RoaringBitmap,
|
||||
document_scores: Vec<(u32, ScoreWithRatio)>,
|
||||
degraded: bool,
|
||||
used_negative_operator: bool,
|
||||
}
|
||||
|
||||
type ScoreWithRatio = (Vec<ScoreDetails>, f32);
|
||||
|
@ -78,6 +79,7 @@ impl ScoreWithRatioResult {
|
|||
candidates: results.candidates,
|
||||
document_scores,
|
||||
degraded: results.degraded,
|
||||
used_negative_operator: results.used_negative_operator,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,6 +115,7 @@ impl ScoreWithRatioResult {
|
|||
documents_ids,
|
||||
document_scores,
|
||||
degraded: left.degraded | right.degraded,
|
||||
used_negative_operator: left.used_negative_operator | right.used_negative_operator,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -183,6 +183,7 @@ impl<'a> Search<'a> {
|
|||
documents_ids,
|
||||
document_scores,
|
||||
degraded,
|
||||
used_negative_operator,
|
||||
} = match self.vector.as_ref() {
|
||||
Some(vector) => execute_vector_search(
|
||||
&mut ctx,
|
||||
|
@ -221,7 +222,14 @@ impl<'a> Search<'a> {
|
|||
None => MatchingWords::default(),
|
||||
};
|
||||
|
||||
Ok(SearchResult { matching_words, candidates, document_scores, documents_ids, degraded })
|
||||
Ok(SearchResult {
|
||||
matching_words,
|
||||
candidates,
|
||||
document_scores,
|
||||
documents_ids,
|
||||
degraded,
|
||||
used_negative_operator,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -272,6 +280,7 @@ pub struct SearchResult {
|
|||
pub documents_ids: Vec<DocumentId>,
|
||||
pub document_scores: Vec<Vec<ScoreDetails>>,
|
||||
pub degraded: bool,
|
||||
pub used_negative_operator: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
|
|
|
@ -571,6 +571,7 @@ pub fn execute_vector_search(
|
|||
documents_ids: docids,
|
||||
located_query_terms: None,
|
||||
degraded,
|
||||
used_negative_operator: false,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -594,6 +595,7 @@ pub fn execute_search(
|
|||
) -> Result<PartialSearchResult> {
|
||||
check_sort_criteria(ctx, sort_criteria.as_ref())?;
|
||||
|
||||
let mut used_negative_operator = false;
|
||||
let mut located_query_terms = None;
|
||||
let query_terms = if let Some(query) = query {
|
||||
let span = tracing::trace_span!(target: "search::tokens", "tokenizer_builder");
|
||||
|
@ -636,6 +638,7 @@ pub fn execute_search(
|
|||
|
||||
let (query_terms, negative_words) =
|
||||
located_query_terms_from_tokens(ctx, tokens, words_limit)?;
|
||||
used_negative_operator = !negative_words.is_empty();
|
||||
|
||||
let ignored_documents = resolve_negative_words(ctx, &negative_words)?;
|
||||
universe -= ignored_documents;
|
||||
|
@ -710,6 +713,7 @@ pub fn execute_search(
|
|||
documents_ids: docids,
|
||||
located_query_terms,
|
||||
degraded,
|
||||
used_negative_operator,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -772,4 +776,5 @@ pub struct PartialSearchResult {
|
|||
pub document_scores: Vec<Vec<ScoreDetails>>,
|
||||
|
||||
pub degraded: bool,
|
||||
pub used_negative_operator: bool,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue