-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Specifying `index_phrases: true` on a text field mapping will add a subsidiary [field]._index_phrase field, indexing two-term shingles from the parent field. The parent analysis chain is re-used, wrapped with a FixedShingleFilter. At query time, if a phrase match query is executed, the mapping will redirect it to run against the subsidiary field. This should trade faster phrase querying for a larger index and longer indexing times. Relates to #27049
- Loading branch information
1 parent
dc8a4fb
commit 0427339
Showing
8 changed files
with
457 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
67 changes: 67 additions & 0 deletions
67
rest-api-spec/src/main/resources/rest-api-spec/test/search/200_index_phrase_search.yml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--- | ||
"search with indexed phrases": | ||
- skip: | ||
version: " - 6.99.99" | ||
reason: index_phrase is only available as of 7.0.0 | ||
- do: | ||
indices.create: | ||
index: test | ||
body: | ||
mappings: | ||
test: | ||
properties: | ||
text: | ||
type: text | ||
index_phrases: true | ||
|
||
- do: | ||
index: | ||
index: test | ||
type: test | ||
id: 1 | ||
body: { text: "peter piper picked a peck of pickled peppers" } | ||
|
||
- do: | ||
indices.refresh: | ||
index: [test] | ||
|
||
- do: | ||
search: | ||
index: test | ||
body: | ||
query: | ||
match_phrase: | ||
text: | ||
query: "peter piper" | ||
|
||
- match: {hits.total: 1} | ||
|
||
- do: | ||
search: | ||
index: test | ||
q: '"peter piper"~1' | ||
df: text | ||
|
||
- match: {hits.total: 1} | ||
|
||
- do: | ||
search: | ||
index: test | ||
body: | ||
query: | ||
match_phrase: | ||
text: "peter piper picked" | ||
|
||
- match: {hits.total: 1} | ||
|
||
- do: | ||
search: | ||
index: test | ||
body: | ||
query: | ||
match_phrase: | ||
text: "piper" | ||
|
||
- match: {hits.total: 1} | ||
|
||
|
This file contains 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
Oops, something went wrong.