2013-08-29 07:24:34 +08:00
|
|
|
[[query-dsl-span-first-query]]
|
2019-07-18 22:18:11 +08:00
|
|
|
=== Span first query
|
|
|
|
++++
|
|
|
|
<titleabbrev>Span first</titleabbrev>
|
|
|
|
++++
|
2013-08-29 07:24:34 +08:00
|
|
|
|
|
|
|
Matches spans near the beginning of a field. The span first query maps
|
|
|
|
to Lucene `SpanFirstQuery`. Here is an example:
|
|
|
|
|
2019-09-09 22:45:37 +08:00
|
|
|
[source,console]
|
2013-08-29 07:24:34 +08:00
|
|
|
--------------------------------------------------
|
2016-05-24 17:58:43 +08:00
|
|
|
GET /_search
|
2013-08-29 07:24:34 +08:00
|
|
|
{
|
2020-07-22 00:24:26 +08:00
|
|
|
"query": {
|
|
|
|
"span_first": {
|
|
|
|
"match": {
|
2020-08-04 00:49:56 +08:00
|
|
|
"span_term": { "user.id": "kimchy" }
|
2020-07-22 00:24:26 +08:00
|
|
|
},
|
|
|
|
"end": 3
|
2013-08-29 07:24:34 +08:00
|
|
|
}
|
2020-07-22 00:24:26 +08:00
|
|
|
}
|
|
|
|
}
|
2013-08-29 07:24:34 +08:00
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
The `match` clause can be any other span type query. The `end` controls
|
|
|
|
the maximum end position permitted in a match.
|