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-17 14:55:56 -04:00
|
|
|
{
|
2013-08-28 19:24:34 -04:00
|
|
|
"prefix" : { "user" : "ki" }
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
A boost can also be associated with the query:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2016-05-17 14:55:56 -04:00
|
|
|
{
|
2013-08-28 19:24:34 -04:00
|
|
|
"prefix" : { "user" : { "value" : "ki", "boost" : 2.0 } }
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
Or :
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2016-05-17 14:55:56 -04:00
|
|
|
{
|
2013-08-28 19:24:34 -04:00
|
|
|
"prefix" : { "user" : { "prefix" : "ki", "boost" : 2.0 } }
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
|
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.
|