[DOCS] Move named query content to bool query (#60748) (#60772)

This commit is contained in:
James Rodewig 2020-08-05 13:42:13 -04:00 committed by GitHub
parent d4d58e70f5
commit 815f3d526e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 37 deletions

View File

@ -19,7 +19,7 @@ The top_hits aggregation returns regular search hits, because of this many per h
* <<highlighting,Highlighting>>
* <<request-body-search-explain,Explain>>
* <<request-body-search-queries-and-filters,Named filters and queries>>
* <<named-queries,Named queries>>
* <<source-filtering,Source filtering>>
* <<request-body-search-stored-fields,Stored fields>>
* <<request-body-search-script-fields,Script fields>>

View File

@ -142,9 +142,30 @@ GET _search
}
---------------------------------
==== Using named queries to see which clauses matched
[[named-queries]]
==== Named queries
If you need to know which of the clauses in the bool query matched the documents
returned from the query, you can use
<<request-body-search-queries-and-filters,named queries>> to assign a name to
each clause.
Each query accepts a `_name` in its top level definition. You can use named
queries to track which queries matched returned documents. If named queries are
used, the response includes a `matched_queries` property for each hit.
[source,console]
----
GET /_search
{
"query": {
"bool": {
"should": [
{ "match": { "name.first": { "query": "shay", "_name": "first" } } },
{ "match": { "name.last": { "query": "banon", "_name": "last" } } }
],
"filter": {
"terms": {
"name.last": [ "banon", "kimchy" ],
"_name": "test"
}
}
}
}
}
----

View File

@ -87,7 +87,7 @@ See <<request-body-search-min-score>>.
[role="exclude",id="search-request-named-queries-and-filters"]
=== Named query parameter for request body search API
See <<request-body-search-queries-and-filters>>.
See <<named-queries>>.
[role="exclude",id="search-request-post-filter"]
=== Post filter parameter for request body search API
@ -1007,6 +1007,11 @@ See <<highlighting>>.
[role="exclude",id="highlighter-internal-work"]
==== How highlighters work internally
[role="exclude",id="request-body-search-queries-and-filters"]
=== Named queries
See <<named-queries>.
See <<how-es-highlighters-work-internally>>.
[role="exclude",id="request-body-search-scroll"]

View File

@ -129,7 +129,10 @@ include::request/inner-hits.asciidoc[]
include::request/min-score.asciidoc[]
include::request/named-queries-and-filters.asciidoc[]
[[request-body-search-queries-and-filters]]
==== Named queries
See <<named-queries>>.
include::request/post-filter.asciidoc[]

View File

@ -1,29 +0,0 @@
[[request-body-search-queries-and-filters]]
==== Named Queries
Each filter and query can accept a `_name` in its top level definition.
[source,console]
--------------------------------------------------
GET /_search
{
"query": {
"bool": {
"should": [
{ "match": { "name.first": { "query": "shay", "_name": "first" } } },
{ "match": { "name.last": { "query": "banon", "_name": "last" } } }
],
"filter": {
"terms": {
"name.last": [ "banon", "kimchy" ],
"_name": "test"
}
}
}
}
}
--------------------------------------------------
The search response will include for each hit the `matched_queries` it matched on. The tagging of queries and filters
only make sense for the `bool` query.