fix(query-parser): honor phrase prefix and slop on JSON fields#2966
Open
DavIvek wants to merge 1 commit into
Open
fix(query-parser): honor phrase prefix and slop on JSON fields#2966DavIvek wants to merge 1 commit into
DavIvek wants to merge 1 commit into
Conversation
Phrase prefix (`"..."*`) and slop (`"..."~N`) were silently dropped on JSON fields. `generate_literals_for_json_object` hard-coded `slop: 0` and `prefix: false`, so a query like `data.name:"foo bar"*` degraded to an exact phrase, even though the underlying `PhrasePrefixQuery` already supports JSON-path terms. Thread `slop`/`prefix` through the JSON branch, exactly as the `Str` branch already does, and add the "phrase prefix requires at least two terms" guard for the single-token case (mirroring `generate_literals_for_str`). Tests added as JSON analogues of the existing text-field tests: - test_phrase_prefix_on_json_field - test_phrase_prefix_too_short_on_json_field - test_phrase_slop_on_json_field This aligns JSON fields with the phrase `~`/`*` behavior already documented for `QueryParser`.
bbab186 to
edbb4b4
Compare
|
Nice! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phrase prefix (
"..."*) and slop ("..."~N) were silently dropped on JSON fields.generate_literals_for_json_objecthard-codedslop: 0andprefix: false, so a query likedata.name:"foo bar"*degraded to an exact phrase on the JSON field — even though the underlyingPhrasePrefixQueryalready supports JSON-path terms.This threads
slop/prefixthrough the JSON branch, exactly as theStrbranch (generate_literals_for_str) already does, and adds the "phrase prefix requires at least two terms" guard for the single-token case.Tests
Added as JSON analogues of the existing text-field tests (
test_phrase_prefix,test_phrase_prefix_too_short,test_phrase_slop):test_phrase_prefix_on_json_fieldtest_phrase_prefix_too_short_on_json_fieldtest_phrase_slop_on_json_fieldThis aligns JSON fields with the phrase
~/*behavior already documented forQueryParser.