46 lines
1.4 KiB
Plaintext
46 lines
1.4 KiB
Plaintext
[[query-dsl-span-multi-term-query]]
|
|
=== Span Multi Term Query
|
|
|
|
The `span_multi` query allows you to wrap a `multi term query` (one of wildcard,
|
|
fuzzy, prefix, range or regexp query) as a `span query`, so
|
|
it can be nested. Example:
|
|
|
|
[source,js]
|
|
--------------------------------------------------
|
|
GET /_search
|
|
{
|
|
"query": {
|
|
"span_multi":{
|
|
"match":{
|
|
"prefix" : { "user" : { "value" : "ki" } }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
--------------------------------------------------
|
|
// CONSOLE
|
|
|
|
A boost can also be associated with the query:
|
|
|
|
[source,js]
|
|
--------------------------------------------------
|
|
GET /_search
|
|
{
|
|
"query": {
|
|
"span_multi":{
|
|
"match":{
|
|
"prefix" : { "user" : { "value" : "ki", "boost" : 1.08 } }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
--------------------------------------------------
|
|
// CONSOLE
|
|
|
|
WARNING: By default `span_multi queries are rewritten to a `span_or` query
|
|
containing **all** the expanded terms. This can be expensive if the number of expanded
|
|
terms is large. 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, you can
|
|
activate the <<index-prefix-config,`index_prefixes`>> field option of the `text` field instead. This will
|
|
rewrite any prefix query on the field to a a single term query that matches the indexed prefix. |