Elasticsearch: Span_near and substring match Elasticsearch: Span_near and substring match elasticsearch elasticsearch

Elasticsearch: Span_near and substring match


POST /bluray/movies/_search{  "query": {    "bool": {      "should": [        {          "span_near": {            "clauses": [              {                "span_term": {                  "genre": "women's"                }              },              {                "span_term": {                  "genre": "cream"                }              }            ],            "collect_payloads": false,            "slop": 12,            "in_order": true          }        },{          "match": {            "genre": {              "query": "women's cream",              "analyzer": "standard",              "minimum_should_match": "99%"            }          }        }      ]    }  }}

Which give the following output as your expected:

    {  "took": 2,  "timed_out": false,  "_shards": {    "total": 5,    "successful": 5,    "failed": 0  },  "hits": {    "total": 6,    "max_score": 0.7841132,    "hits": [      {        "_index": "bluray",        "_type": "movies",        "_id": "4",        "_score": 0.7841132,        "_source": {          "genre": "women's cream"        }      },      {        "_index": "bluray",        "_type": "movies",        "_id": "5",        "_score": 0.56961054,        "_source": {          "genre": "women's wrinkle cream"        }      },      {        "_index": "bluray",        "_type": "movies",        "_id": "6",        "_score": 0.35892165,        "_source": {          "genre": "women's advanced wrinkle cream"        }      },      {        "_index": "bluray",        "_type": "movies",        "_id": "3",        "_score": 0.2876821,        "_source": {          "genre": "men's advanced wrinkle cream"        }      },      {        "_index": "bluray",        "_type": "movies",        "_id": "1",        "_score": 0.25811607,        "_source": {          "genre": "men's cream"        }      },      {        "_index": "bluray",        "_type": "movies",        "_id": "2",        "_score": 0.11750762,        "_source": {          "genre": "men's wrinkle cream"        }      }    ]  }}