2013-08-28 19:24:34 -04:00
|
|
|
[[query-dsl-span-multi-term-query]]
|
2019-07-18 10:18:11 -04:00
|
|
|
=== Span multi-term query
|
|
|
|
++++
|
|
|
|
<titleabbrev>Span multi-term</titleabbrev>
|
|
|
|
++++
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2015-02-05 15:23:52 -05:00
|
|
|
The `span_multi` query allows you to wrap a `multi term query` (one of wildcard,
|
2017-01-23 11:33:12 -05:00
|
|
|
fuzzy, prefix, range or regexp query) as a `span query`, so
|
2013-08-28 19:24:34 -04:00
|
|
|
it can be nested. Example:
|
|
|
|
|
2019-09-09 12:35:50 -04:00
|
|
|
[source,console]
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
2016-05-24 05:58:43 -04:00
|
|
|
GET /_search
|
2013-08-28 19:24:34 -04:00
|
|
|
{
|
2020-07-21 15:49:58 -04:00
|
|
|
"query": {
|
|
|
|
"span_multi": {
|
|
|
|
"match": {
|
|
|
|
"prefix": { "user": { "value": "ki" } }
|
|
|
|
}
|
2013-08-28 19:24:34 -04:00
|
|
|
}
|
2020-07-21 15:49:58 -04:00
|
|
|
}
|
2013-08-28 19:24:34 -04:00
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
A boost can also be associated with the query:
|
|
|
|
|
2019-09-09 12:35:50 -04:00
|
|
|
[source,console]
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
2016-05-24 05:58:43 -04:00
|
|
|
GET /_search
|
2013-08-28 19:24:34 -04:00
|
|
|
{
|
2020-07-21 15:49:58 -04:00
|
|
|
"query": {
|
|
|
|
"span_multi": {
|
|
|
|
"match": {
|
|
|
|
"prefix": { "user": { "value": "ki", "boost": 1.08 } }
|
|
|
|
}
|
2013-08-28 19:24:34 -04:00
|
|
|
}
|
2020-07-21 15:49:58 -04:00
|
|
|
}
|
2013-08-28 19:24:34 -04:00
|
|
|
}
|
|
|
|
--------------------------------------------------
|
2018-06-04 15:48:56 -04:00
|
|
|
|
2018-06-07 03:34:39 -04:00
|
|
|
WARNING: `span_multi` queries will hit too many clauses failure if the number of terms that match the query exceeds the
|
|
|
|
boolean query limit (defaults to 1024).To avoid an unbounded expansion you can set the <<query-dsl-multi-term-rewrite,
|
|
|
|
rewrite method>> of the multi term query to `top_terms_*` rewrite. Or, if you use `span_multi` on `prefix` query only,
|
2018-11-22 04:20:46 -05:00
|
|
|
you can activate the <<index-prefixes,`index_prefixes`>> field option of the `text` field instead. This will
|
2018-08-28 07:16:43 -04:00
|
|
|
rewrite any prefix query on the field to a single term query that matches the indexed prefix.
|
2018-06-07 03:34:39 -04:00
|
|
|
|