perf: deduplicate queries (#2698)

* deduplicate queries

Deduplicate queries in the UserInputAst after parsing queries

* add return type
This commit is contained in:
PSeitz-dd
2025-09-22 12:16:58 +02:00
committed by GitHub
parent 85010b589a
commit 70da310b2d
7 changed files with 59 additions and 21 deletions

View File

@@ -672,7 +672,7 @@ impl QueryParser {
}
UserInputAst::Boost(ast, boost) => {
let (ast, errors) = self.compute_logical_ast_with_occur_lenient(*ast);
(ast.boost(boost as Score), errors)
(ast.boost(boost.into_inner() as Score), errors)
}
UserInputAst::Leaf(leaf) => {
let (ast, errors) = self.compute_logical_ast_from_leaf_lenient(*leaf);
@@ -2050,6 +2050,16 @@ mod test {
);
}
#[test]
pub fn test_deduplication() {
let query = "be be";
test_parse_query_to_logical_ast_helper(
query,
"(Term(field=0, type=Str, \"be\") Term(field=1, type=Str, \"be\"))",
false,
);
}
#[test]
pub fn test_regex() {
let expected_regex = tantivy_fst::Regex::new(r".*b").unwrap();