I need to write the query for below scenario: Ex: The car will be getting close to me but I am unable to stop it. or The car is too close to me but I am unable to stop it.
like:
Span_near(span_or("getting close", "is too close"), span_or(stopped, stop, stopping))
- the distance between either "getting close" or "is too close" and from stopped/stop/stopping should be 10
The below query I tried:
GET /_search
{
"query": {
"bool":{
"should":[
{
"span_near": {
"clauses":
[
{"span_or":
{"clauses":[
{"span_near": {
"clauses": [
{ "span_term": { "textContent": "getting" }},
{ "span_term": { "textContent": "close"}}],
"slop": 0,
"in_order": true
}},
{"span_near": {
"clauses": [
{ "span_term": { "textContent": "is" }},
{ "span_term": { "textContent": "too" }},
{ "span_term": { "textContent": "close"}}],
"slop": 0,
"in_order": true
}}
]}},
{"span_or":
{"clauses":[{"span_term": {"textContent": "stopped"}},
{"span_term": {"textContent": "stop"}},
{"span_term": {"textContent": "stopping"}}]}}
],
"slop":10,
"in_order": false
}
}
]
}
}
}
Can anyone suggest the alternate way to do it.
Thanks in advance