elasticsearch - Elastic search combining queries and nested queries together -
i've been reading elasticsearch queries time , documentation doesn't seem helpful of queries. i'm trying documents
((field1=keyword1 or field2=keyword1) , (field1=keyword2 or field2=keyword2)) , (field3=keyword3 ) , (field4!=keyword4)).
the document refered https://dzone.com/articles/23-useful-elasticsearch-example-queries , when trying execute of queries in sense api extension in chrome, had syntax errors in it. eg:
{ "query": { "bool": { "must": { "bool" : { "should": [ { "match": { "title": "elasticsearch" }}, { "match": { "title": "solr" }} ] } }, "must": { "match": { "authors": "clinton gormely" }}, "must_not": { "match": {"authors": "radu gheorge" }} } } }
it gives "duplicate must. syntax error".
could forming query?
thanks.
you have must twice in same level. try this
{ "query": { "bool": { "must": [{ "bool" : { "should": [ { "match": { "title": "elasticsearch" }}, { "match": { "title": "solr" }} ] } }, { "match": { "authors": "clinton gormely" }}], "must_not": { "match": {"authors": "radu gheorge" }} } } }
wiki
Comments
Post a Comment