Skip to content

fix(query-parser): honor phrase prefix and slop on JSON fields#2966

Open
DavIvek wants to merge 1 commit into
quickwit-oss:mainfrom
memgraph:json-phrase-prefix
Open

fix(query-parser): honor phrase prefix and slop on JSON fields#2966
DavIvek wants to merge 1 commit into
quickwit-oss:mainfrom
memgraph:json-phrase-prefix

Conversation

@DavIvek

@DavIvek DavIvek commented Jun 18, 2026

Copy link
Copy Markdown

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 on the JSON field — even though the underlying PhrasePrefixQuery already supports JSON-path terms.

This threads slop/prefix through the JSON branch, exactly as the Str branch (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_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.

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`.
@DavIvek DavIvek force-pushed the json-phrase-prefix branch from bbab186 to edbb4b4 Compare June 18, 2026 13:39
@Josipmrden

Copy link
Copy Markdown

Nice!

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.

2 participants