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

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -