2013-08-28 19:24:34 -04:00
|
|
|
[[query-dsl-span-first-query]]
|
2019-07-18 10:18:11 -04:00
|
|
|
=== Span first query
|
|
|
|
++++
|
|
|
|
<titleabbrev>Span first</titleabbrev>
|
|
|
|
++++
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
Matches spans near the beginning of a field. The span first query maps
|
|
|
|
to Lucene `SpanFirstQuery`. Here is an 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
|
|
|
{
|
2016-05-24 05:58:43 -04:00
|
|
|
"query": {
|
|
|
|
"span_first" : {
|
|
|
|
"match" : {
|
|
|
|
"span_term" : { "user" : "kimchy" }
|
|
|
|
},
|
|
|
|
"end" : 3
|
|
|
|
}
|
2013-08-28 19:24:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
The `match` clause can be any other span type query. The `end` controls
|
|
|
|
the maximum end position permitted in a match.
|