mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-25 07:37:19 -04:00
[DOCS] update match query documentation
Now the `match` query has been split out into `match`, `match_phrase` and `match_phrase_prefix` we need to update the docs to remove the deprecated syntax
This commit is contained in:
parent
bdc70df319
commit
c20c49963f
4 changed files with 72 additions and 102 deletions
|
@ -34,6 +34,10 @@ The queries in this group are:
|
||||||
|
|
||||||
include::match-query.asciidoc[]
|
include::match-query.asciidoc[]
|
||||||
|
|
||||||
|
include::match-phrase-query.asciidoc[]
|
||||||
|
|
||||||
|
include::match-phrase-prefix-query.asciidoc[]
|
||||||
|
|
||||||
include::multi-match-query.asciidoc[]
|
include::multi-match-query.asciidoc[]
|
||||||
|
|
||||||
include::common-terms-query.asciidoc[]
|
include::common-terms-query.asciidoc[]
|
||||||
|
@ -41,4 +45,3 @@ include::common-terms-query.asciidoc[]
|
||||||
include::query-string-query.asciidoc[]
|
include::query-string-query.asciidoc[]
|
||||||
|
|
||||||
include::simple-query-string-query.asciidoc[]
|
include::simple-query-string-query.asciidoc[]
|
||||||
|
|
||||||
|
|
32
docs/reference/query-dsl/match-phrase-prefix-query.asciidoc
Normal file
32
docs/reference/query-dsl/match-phrase-prefix-query.asciidoc
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
[[query-dsl-match-query-phrase-prefix]]
|
||||||
|
=== Match Phrase Prefix Query
|
||||||
|
|
||||||
|
The `match_phrase_prefix` is the same as `match_phrase`, except that it
|
||||||
|
allows for prefix matches on the last term in the text. For example:
|
||||||
|
|
||||||
|
[source,js]
|
||||||
|
--------------------------------------------------
|
||||||
|
{
|
||||||
|
"match_phrase_prefix" : {
|
||||||
|
"message" : "this is a test"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--------------------------------------------------
|
||||||
|
|
||||||
|
It accepts the same parameters as the phrase type. In addition, it also
|
||||||
|
accepts a `max_expansions` parameter that can control to how many
|
||||||
|
prefixes the last term will be expanded. It is highly recommended to set
|
||||||
|
it to an acceptable value to control the execution time of the query.
|
||||||
|
For example:
|
||||||
|
|
||||||
|
[source,js]
|
||||||
|
--------------------------------------------------
|
||||||
|
{
|
||||||
|
"match_phrase_prefix" : {
|
||||||
|
"message" : {
|
||||||
|
"query" : "this is a test",
|
||||||
|
"max_expansions" : 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--------------------------------------------------
|
33
docs/reference/query-dsl/match-phrase-query.asciidoc
Normal file
33
docs/reference/query-dsl/match-phrase-query.asciidoc
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
[[query-dsl-match-query-phrase]]
|
||||||
|
=== Match Phrase Query
|
||||||
|
|
||||||
|
The `match_phrase` query analyzes the text and creates a `phrase` query
|
||||||
|
out of the analyzed text. For example:
|
||||||
|
|
||||||
|
[source,js]
|
||||||
|
--------------------------------------------------
|
||||||
|
{
|
||||||
|
"match_phrase" : {
|
||||||
|
"message" : "this is a test"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--------------------------------------------------
|
||||||
|
|
||||||
|
A phrase query matches terms up to a configurable `slop`
|
||||||
|
(which defaults to 0) in any order. Transposed terms have a slop of 2.
|
||||||
|
|
||||||
|
The `analyzer` can be set to control which analyzer will perform the
|
||||||
|
analysis process on the text. It defaults to the field explicit mapping
|
||||||
|
definition, or the default search analyzer, for example:
|
||||||
|
|
||||||
|
[source,js]
|
||||||
|
--------------------------------------------------
|
||||||
|
{
|
||||||
|
"match_phrase" : {
|
||||||
|
"message" : {
|
||||||
|
"query" : "this is a test",
|
||||||
|
"analyzer" : "my_analyzer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--------------------------------------------------
|
|
@ -2,7 +2,7 @@
|
||||||
=== Match Query
|
=== Match Query
|
||||||
|
|
||||||
|
|
||||||
A family of `match` queries that accepts text/numerics/dates, analyzes
|
`match` queries accept text/numerics/dates, analyzes
|
||||||
them, and constructs a query. For example:
|
them, and constructs a query. For example:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
|
@ -17,12 +17,10 @@ them, and constructs a query. For example:
|
||||||
Note, `message` is the name of a field, you can substitute the name of
|
Note, `message` is the name of a field, you can substitute the name of
|
||||||
any field (including `_all`) instead.
|
any field (including `_all`) instead.
|
||||||
|
|
||||||
There are three types of `match` query: `boolean`, `phrase`, and `phrase_prefix`:
|
|
||||||
|
|
||||||
[[query-dsl-match-query-boolean]]
|
[[query-dsl-match-query-boolean]]
|
||||||
==== boolean
|
==== match
|
||||||
|
|
||||||
The default `match` query is of type `boolean`. It means that the text
|
The `match` query is of type `boolean`. It means that the text
|
||||||
provided is analyzed and the analysis process constructs a boolean query
|
provided is analyzed and the analysis process constructs a boolean query
|
||||||
from the provided text. The `operator` flag can be set to `or` or `and`
|
from the provided text. The `operator` flag can be set to `or` or `and`
|
||||||
to control the boolean clauses (defaults to `or`). The minimum number of
|
to control the boolean clauses (defaults to `or`). The minimum number of
|
||||||
|
@ -127,102 +125,6 @@ IMPORTANT: The `cutoff_frequency` option operates on a per-shard-level. This mea
|
||||||
that when trying it out on test indexes with low document numbers you
|
that when trying it out on test indexes with low document numbers you
|
||||||
should follow the advice in {defguide}/relevance-is-broken.html[Relevance is broken].
|
should follow the advice in {defguide}/relevance-is-broken.html[Relevance is broken].
|
||||||
|
|
||||||
[[query-dsl-match-query-phrase]]
|
|
||||||
==== phrase
|
|
||||||
|
|
||||||
The `match_phrase` query analyzes the text and creates a `phrase` query
|
|
||||||
out of the analyzed text. For example:
|
|
||||||
|
|
||||||
[source,js]
|
|
||||||
--------------------------------------------------
|
|
||||||
{
|
|
||||||
"match_phrase" : {
|
|
||||||
"message" : "this is a test"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
--------------------------------------------------
|
|
||||||
|
|
||||||
Since `match_phrase` is only a `type` of a `match` query, it can also be
|
|
||||||
used in the following manner:
|
|
||||||
|
|
||||||
[source,js]
|
|
||||||
--------------------------------------------------
|
|
||||||
{
|
|
||||||
"match" : {
|
|
||||||
"message" : {
|
|
||||||
"query" : "this is a test",
|
|
||||||
"type" : "phrase"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
--------------------------------------------------
|
|
||||||
|
|
||||||
A phrase query matches terms up to a configurable `slop`
|
|
||||||
(which defaults to 0) in any order. Transposed terms have a slop of 2.
|
|
||||||
|
|
||||||
The `analyzer` can be set to control which analyzer will perform the
|
|
||||||
analysis process on the text. It defaults to the field explicit mapping
|
|
||||||
definition, or the default search analyzer, for example:
|
|
||||||
|
|
||||||
[source,js]
|
|
||||||
--------------------------------------------------
|
|
||||||
{
|
|
||||||
"match_phrase" : {
|
|
||||||
"message" : {
|
|
||||||
"query" : "this is a test",
|
|
||||||
"analyzer" : "my_analyzer"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
--------------------------------------------------
|
|
||||||
|
|
||||||
[[query-dsl-match-query-phrase-prefix]]
|
|
||||||
==== match_phrase_prefix
|
|
||||||
|
|
||||||
The `match_phrase_prefix` is the same as `match_phrase`, except that it
|
|
||||||
allows for prefix matches on the last term in the text. For example:
|
|
||||||
|
|
||||||
[source,js]
|
|
||||||
--------------------------------------------------
|
|
||||||
{
|
|
||||||
"match_phrase_prefix" : {
|
|
||||||
"message" : "this is a test"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
--------------------------------------------------
|
|
||||||
|
|
||||||
Or:
|
|
||||||
|
|
||||||
[source,js]
|
|
||||||
--------------------------------------------------
|
|
||||||
{
|
|
||||||
"match" : {
|
|
||||||
"message" : {
|
|
||||||
"query" : "this is a test",
|
|
||||||
"type" : "phrase_prefix"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
--------------------------------------------------
|
|
||||||
|
|
||||||
It accepts the same parameters as the phrase type. In addition, it also
|
|
||||||
accepts a `max_expansions` parameter that can control to how many
|
|
||||||
prefixes the last term will be expanded. It is highly recommended to set
|
|
||||||
it to an acceptable value to control the execution time of the query.
|
|
||||||
For example:
|
|
||||||
|
|
||||||
[source,js]
|
|
||||||
--------------------------------------------------
|
|
||||||
{
|
|
||||||
"match_phrase_prefix" : {
|
|
||||||
"message" : {
|
|
||||||
"query" : "this is a test",
|
|
||||||
"max_expansions" : 10
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
--------------------------------------------------
|
|
||||||
|
|
||||||
.Comparison to query_string / field
|
.Comparison to query_string / field
|
||||||
**************************************************
|
**************************************************
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue