In ElasticSearch, how to combine a `span_near` and a `term`? In ElasticSearch, how to combine a `span_near` and a `term`? elasticsearch elasticsearch

In ElasticSearch, how to combine a `span_near` and a `term`?


{  "query": {    "filtered": {      "query": {        "span_near": {          "clauses": [            {              "span_term": {                "file.contents": "charstreams"              }            }          ],          "slop": 0,          "in_order": true        }      },      "filter": {        "term": {          "file.extension": "java"        }      }    }  }}

Also, since you're setting slop to 0 and in_order to true, you might want to consider using https://www.elastic.co/guide/en/elasticsearch/guide/current/phrase-matching.html instead.