Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable usage of FuzzyTermQuery for specific fields via QueryParser #1750

Merged
merged 5 commits into from
Jan 4, 2023
Merged

Enable usage of FuzzyTermQuery for specific fields via QueryParser #1750

merged 5 commits into from
Jan 4, 2023

Conversation

adamreichold
Copy link
Collaborator

Following the lead of QueryParser::set_field_boost, this adds QueryParser::set_field_fuzzy which sets whether literals will be matched against the given field using FuzzyTermQuery instead of TermQuery using the given parameters prefix, distance and transposition_cost_one.

My personal use case for this is a single category-like STRING field which I would like to include in default set but as I expect users to make spelling mistakes or use prefixes instead of the full categories.

@codecov-commenter
Copy link

codecov-commenter commented Dec 31, 2022

Codecov Report

Merging #1750 (9a22dbd) into main (b22f966) will increase coverage by 0.00%.
The diff coverage is 99.00%.

@@           Coverage Diff           @@
##             main    #1750   +/-   ##
=======================================
  Coverage   94.13%   94.14%           
=======================================
  Files         267      267           
  Lines       50900    50966   +66     
=======================================
+ Hits        47917    47984   +67     
+ Misses       2983     2982    -1     
Impacted Files Coverage Δ
src/query/query_parser/query_parser.rs 95.09% <98.63%> (+0.19%) ⬆️
src/directory/ram_directory.rs 90.50% <100.00%> (ø)
src/directory/watch_event_router.rs 95.79% <100.00%> (ø)
src/indexer/json_term_writer.rs 99.79% <100.00%> (ø)
src/indexer/segment_updater.rs 95.44% <100.00%> (ø)
src/postings/compression/mod.rs 100.00% <100.00%> (ø)
src/query/boolean_query/boolean_query.rs 93.33% <100.00%> (+0.66%) ⬆️
src/query/boolean_query/boolean_weight.rs 93.43% <100.00%> (ø)
src/query/query_parser/logical_ast.rs 80.00% <100.00%> (ø)
src/schema/text_options.rs 100.00% <100.00%> (ø)
... and 8 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@fulmicoton
Copy link
Collaborator

Thank you @adamreichold

@fulmicoton fulmicoton merged commit 2080c37 into quickwit-oss:main Jan 4, 2023
@adamreichold adamreichold deleted the set-field-fuzzy branch January 4, 2023 10:24
This was referenced Jan 13, 2023
Hodkinson pushed a commit to Hodkinson/tantivy that referenced this pull request Jan 30, 2023
…uickwit-oss#1750)

* Make nightly Clippy mostly happy.

* Document how to produce TermSetQuery queries using QueryParser.

* Enable construction of queries using FuzzyTermQuery via the QueryParser

* Use FxHashMap instead of HashMap in the QueryParser as these hash tables are not exposed to DoS attacks.

* Use a struct instead of a tuple to improve readability.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants