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
|
|
|
{
|
2020-07-21 15:49:58 -04:00
|
|
|
"query": {
|
|
|
|
"span_first": {
|
|
|
|
"match": {
|
2020-08-03 13:31:19 -04:00
|
|
|
"span_term": { "user.id": "kimchy" }
|
2020-07-21 15:49:58 -04:00
|
|
|
},
|
|
|
|
"end": 3
|
2013-08-28 19:24:34 -04:00
|
|
|
}
|
2020-07-21 15:49:58 -04:00
|
|
|
}
|
|
|
|
}
|
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.
|