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