Skip to content

Commit c656159

Browse files
authored
[DOCS] Expand simple query string query's multi-position token section (#68753)
1 parent 20cab22 commit c656159

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

docs/reference/analysis/token-graphs.asciidoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ record the `positionLength` for multi-position tokens. This filters include:
3939
* <<analysis-synonym-graph-tokenfilter,`synonym_graph`>>
4040
* <<analysis-word-delimiter-graph-tokenfilter,`word_delimiter_graph`>>
4141

42+
Some tokenizers, such as the
43+
{plugin}/analysis-nori-tokenizer.html[`nori_tokenizer`], also accurately
44+
decompose compound tokens into multi-position tokens.
45+
4246
In the following graph, `domain name system` and its synonym, `dns`, both have a
4347
position of `0`. However, `dns` has a `positionLength` of `3`. Other tokens in
4448
the graph have a default `positionLength` of `1`.

docs/reference/query-dsl/simple-query-string-query.asciidoc

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,10 @@ query string into tokens. Defaults to the
8686
`default_field`. If no analyzer is mapped, the index's default analyzer is used.
8787

8888
`auto_generate_synonyms_phrase_query`::
89-
(Optional, Boolean) If `true`, <<query-dsl-match-query-phrase,match phrase>>
90-
queries are automatically created for multi-term synonyms. Defaults to `true`.
91-
See <<simple-query-string-synonyms>> for an example.
89+
(Optional, Boolean) If `true`, the parser creates a
90+
<<query-dsl-match-query-phrase,`match_phrase`>> query for each
91+
<<token-graphs-multi-position-tokens,multi-position token>>. Defaults to `true`.
92+
For examples, see <<simple-query-string-synonyms>>.
9293

9394
`flags`::
9495
(Optional, string) List of enabled operators for the
@@ -273,33 +274,36 @@ GET /_search
273274
<1> The `subject` field is three times as important as the `message` field.
274275

275276
[[simple-query-string-synonyms]]
276-
===== Synonyms
277+
===== Multi-position tokens
277278

278-
The `simple_query_string` query supports multi-terms synonym expansion with the <<analysis-synonym-graph-tokenfilter,
279-
synonym_graph>> token filter. When this filter is used, the parser creates a phrase query for each multi-terms synonyms.
280-
For example, the following synonym: `"ny, new york"` would produce:
279+
By default, the `simple_query_string` query parser creates a
280+
<<query-dsl-match-query-phrase,`match_phrase`>> query for each
281+
<<token-graphs-multi-position-tokens,multi-position token>> in the query string.
282+
For example, the parser creates a `match_phrase` query for the multi-word
283+
synonym `ny, new york`:
281284

282285
`(ny OR ("new york"))`
283286

284-
It is also possible to match multi terms synonyms with conjunctions instead:
287+
To match multi-position tokens with an `AND` conjunction instead, set
288+
`auto_generate_synonyms_phrase_query` to `false`:
285289

286290
[source,console]
287-
--------------------------------------------------
291+
----
288292
GET /_search
289293
{
290-
"query": {
291-
"simple_query_string" : {
292-
"query" : "ny city",
293-
"auto_generate_synonyms_phrase_query" : false
294-
}
295-
}
294+
"query": {
295+
"simple_query_string": {
296+
"query": "ny city",
297+
"auto_generate_synonyms_phrase_query": false
298+
}
299+
}
296300
}
297-
--------------------------------------------------
301+
----
298302

299-
The example above creates a boolean query:
303+
For the above example, the parser creates the following
304+
<<query-dsl-bool-query,`bool`>> query:
300305

301306
`(ny OR (new AND york)) city)`
302307

303-
that matches documents with the term `ny` or the conjunction `new AND york`.
304-
By default the parameter `auto_generate_synonyms_phrase_query` is set to `true`.
305-
308+
This `bool` query matches documents with the term `ny` or the conjunction
309+
`new AND york`.

0 commit comments

Comments
 (0)