parent
d4d58e70f5
commit
815f3d526e
|
@ -19,7 +19,7 @@ The top_hits aggregation returns regular search hits, because of this many per h
|
||||||
|
|
||||||
* <<highlighting,Highlighting>>
|
* <<highlighting,Highlighting>>
|
||||||
* <<request-body-search-explain,Explain>>
|
* <<request-body-search-explain,Explain>>
|
||||||
* <<request-body-search-queries-and-filters,Named filters and queries>>
|
* <<named-queries,Named queries>>
|
||||||
* <<source-filtering,Source filtering>>
|
* <<source-filtering,Source filtering>>
|
||||||
* <<request-body-search-stored-fields,Stored fields>>
|
* <<request-body-search-stored-fields,Stored fields>>
|
||||||
* <<request-body-search-script-fields,Script fields>>
|
* <<request-body-search-script-fields,Script fields>>
|
||||||
|
|
|
@ -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
|
Each query accepts a `_name` in its top level definition. You can use named
|
||||||
returned from the query, you can use
|
queries to track which queries matched returned documents. If named queries are
|
||||||
<<request-body-search-queries-and-filters,named queries>> to assign a name to
|
used, the response includes a `matched_queries` property for each hit.
|
||||||
each clause.
|
|
||||||
|
[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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
----
|
||||||
|
|
|
@ -87,7 +87,7 @@ See <<request-body-search-min-score>>.
|
||||||
|
|
||||||
[role="exclude",id="search-request-named-queries-and-filters"]
|
[role="exclude",id="search-request-named-queries-and-filters"]
|
||||||
=== Named query parameter for request body search API
|
=== 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"]
|
[role="exclude",id="search-request-post-filter"]
|
||||||
=== Post filter parameter for request body search API
|
=== Post filter parameter for request body search API
|
||||||
|
@ -1007,6 +1007,11 @@ See <<highlighting>>.
|
||||||
[role="exclude",id="highlighter-internal-work"]
|
[role="exclude",id="highlighter-internal-work"]
|
||||||
==== How highlighters work internally
|
==== How highlighters work internally
|
||||||
|
|
||||||
|
[role="exclude",id="request-body-search-queries-and-filters"]
|
||||||
|
=== Named queries
|
||||||
|
|
||||||
|
See <<named-queries>.
|
||||||
|
|
||||||
See <<how-es-highlighters-work-internally>>.
|
See <<how-es-highlighters-work-internally>>.
|
||||||
|
|
||||||
[role="exclude",id="request-body-search-scroll"]
|
[role="exclude",id="request-body-search-scroll"]
|
||||||
|
|
|
@ -129,7 +129,10 @@ include::request/inner-hits.asciidoc[]
|
||||||
|
|
||||||
include::request/min-score.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[]
|
include::request/post-filter.asciidoc[]
|
||||||
|
|
||||||
|
|
|
@ -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.
|
|
||||||
|
|
Loading…
Reference in New Issue