[DOCS] Expand simple query string query's multi-position token section (#68753)

This commit is contained in:
James Rodewig 2021-02-09 16:07:02 -05:00 committed by GitHub
parent 20cab22875
commit c65615911f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 20 deletions

View file

@ -39,6 +39,10 @@ record the `positionLength` for multi-position tokens. This filters include:
* <<analysis-synonym-graph-tokenfilter,`synonym_graph`>> * <<analysis-synonym-graph-tokenfilter,`synonym_graph`>>
* <<analysis-word-delimiter-graph-tokenfilter,`word_delimiter_graph`>> * <<analysis-word-delimiter-graph-tokenfilter,`word_delimiter_graph`>>
Some tokenizers, such as the
{plugin}/analysis-nori-tokenizer.html[`nori_tokenizer`], also accurately
decompose compound tokens into multi-position tokens.
In the following graph, `domain name system` and its synonym, `dns`, both have a In the following graph, `domain name system` and its synonym, `dns`, both have a
position of `0`. However, `dns` has a `positionLength` of `3`. Other tokens in position of `0`. However, `dns` has a `positionLength` of `3`. Other tokens in
the graph have a default `positionLength` of `1`. the graph have a default `positionLength` of `1`.

View file

@ -86,9 +86,10 @@ query string into tokens. Defaults to the
`default_field`. If no analyzer is mapped, the index's default analyzer is used. `default_field`. If no analyzer is mapped, the index's default analyzer is used.
`auto_generate_synonyms_phrase_query`:: `auto_generate_synonyms_phrase_query`::
(Optional, Boolean) If `true`, <<query-dsl-match-query-phrase,match phrase>> (Optional, Boolean) If `true`, the parser creates a
queries are automatically created for multi-term synonyms. Defaults to `true`. <<query-dsl-match-query-phrase,`match_phrase`>> query for each
See <<simple-query-string-synonyms>> for an example. <<token-graphs-multi-position-tokens,multi-position token>>. Defaults to `true`.
For examples, see <<simple-query-string-synonyms>>.
`flags`:: `flags`::
(Optional, string) List of enabled operators for the (Optional, string) List of enabled operators for the
@ -273,33 +274,36 @@ GET /_search
<1> The `subject` field is three times as important as the `message` field. <1> The `subject` field is three times as important as the `message` field.
[[simple-query-string-synonyms]] [[simple-query-string-synonyms]]
===== Synonyms ===== Multi-position tokens
The `simple_query_string` query supports multi-terms synonym expansion with the <<analysis-synonym-graph-tokenfilter, By default, the `simple_query_string` query parser creates a
synonym_graph>> token filter. When this filter is used, the parser creates a phrase query for each multi-terms synonyms. <<query-dsl-match-query-phrase,`match_phrase`>> query for each
For example, the following synonym: `"ny, new york"` would produce: <<token-graphs-multi-position-tokens,multi-position token>> in the query string.
For example, the parser creates a `match_phrase` query for the multi-word
synonym `ny, new york`:
`(ny OR ("new york"))` `(ny OR ("new york"))`
It is also possible to match multi terms synonyms with conjunctions instead: To match multi-position tokens with an `AND` conjunction instead, set
`auto_generate_synonyms_phrase_query` to `false`:
[source,console] [source,console]
-------------------------------------------------- ----
GET /_search GET /_search
{ {
"query": { "query": {
"simple_query_string" : { "simple_query_string": {
"query" : "ny city", "query": "ny city",
"auto_generate_synonyms_phrase_query" : false "auto_generate_synonyms_phrase_query": false
} }
} }
} }
-------------------------------------------------- ----
The example above creates a boolean query: For the above example, the parser creates the following
<<query-dsl-bool-query,`bool`>> query:
`(ny OR (new AND york)) city)` `(ny OR (new AND york)) city)`
that matches documents with the term `ny` or the conjunction `new AND york`. This `bool` query matches documents with the term `ny` or the conjunction
By default the parameter `auto_generate_synonyms_phrase_query` is set to `true`. `new AND york`.