Commit bbab186
committed
fix(query-parser): honor phrase prefix and slop on JSON fields
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`.1 parent 1e859fd commit bbab186
2 files changed
Lines changed: 50 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
602 | 602 | | |
603 | 603 | | |
604 | 604 | | |
| 605 | + | |
| 606 | + | |
605 | 607 | | |
606 | 608 | | |
607 | 609 | | |
| |||
995 | 997 | | |
996 | 998 | | |
997 | 999 | | |
| 1000 | + | |
998 | 1001 | | |
999 | 1002 | | |
1000 | 1003 | | |
1001 | 1004 | | |
1002 | 1005 | | |
| 1006 | + | |
| 1007 | + | |
1003 | 1008 | | |
1004 | 1009 | | |
1005 | 1010 | | |
| |||
1036 | 1041 | | |
1037 | 1042 | | |
1038 | 1043 | | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
1039 | 1050 | | |
1040 | 1051 | | |
1041 | 1052 | | |
| |||
1048 | 1059 | | |
1049 | 1060 | | |
1050 | 1061 | | |
1051 | | - | |
1052 | | - | |
| 1062 | + | |
| 1063 | + | |
1053 | 1064 | | |
1054 | 1065 | | |
1055 | 1066 | | |
| |||
1963 | 1974 | | |
1964 | 1975 | | |
1965 | 1976 | | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
| 2001 | + | |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
1966 | 2013 | | |
1967 | 2014 | | |
1968 | 2015 | | |
| |||
0 commit comments