2013-08-28 19:24:34 -04:00
|
|
|
[[query-dsl-prefix-query]]
|
2015-06-03 19:59:22 -04:00
|
|
|
=== Prefix Query
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
Matches documents that have fields containing terms with a specified
|
|
|
|
prefix (*not analyzed*). The prefix query maps to Lucene `PrefixQuery`.
|
|
|
|
The following matches documents where the user field contains a term
|
|
|
|
that starts with `ki`:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2016-05-24 05:58:43 -04:00
|
|
|
GET /_search
|
|
|
|
{ "query": {
|
2013-08-28 19:24:34 -04:00
|
|
|
"prefix" : { "user" : "ki" }
|
2016-05-24 05:58:43 -04:00
|
|
|
}
|
2013-08-28 19:24:34 -04:00
|
|
|
}
|
|
|
|
--------------------------------------------------
|
2016-05-24 05:58:43 -04:00
|
|
|
// CONSOLE
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
A boost can also be associated with the query:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2016-05-24 05:58:43 -04:00
|
|
|
GET /_search
|
|
|
|
{ "query": {
|
2013-08-28 19:24:34 -04:00
|
|
|
"prefix" : { "user" : { "value" : "ki", "boost" : 2.0 } }
|
2016-05-24 05:58:43 -04:00
|
|
|
}
|
2013-08-28 19:24:34 -04:00
|
|
|
}
|
|
|
|
--------------------------------------------------
|
2016-05-24 05:58:43 -04:00
|
|
|
// CONSOLE
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2014-09-07 05:32:01 -04:00
|
|
|
This multi term query allows you to control how it gets rewritten using the
|
2013-08-28 19:24:34 -04:00
|
|
|
<<query-dsl-multi-term-rewrite,rewrite>>
|
|
|
|
parameter.
|