Elastic search negate phrase and words in simple query string
Adding a working example with index data,search query, and search result.
Index Data:
{ "name":"test"}{ "name":"game"}{ "name":"the witcher"}{ "name":"the witcher 3"}{ "name":"the"}
Search Query:
{ "query": { "simple_query_string" : { "query": "-(game | novel) -(the witcher 3)", "fields": ["name"], "default_operator": "and" } }}
Search Result:
"hits": [ { "_index": "stof_64133051", "_type": "_doc", "_id": "4", "_score": 2.0, "_source": { "name": "the" } }, { "_index": "stof_64133051", "_type": "_doc", "_id": "3", "_score": 2.0, "_source": { "name": "the witcher" } }, { "_index": "stof_64133051", "_type": "_doc", "_id": "1", "_score": 2.0, "_source": { "name": "test" } } ]