0
votes

I need to use 2 below MUST conditions while writing the elastic search query

MUST - ("source.keyword": "SONAX1")

MUST - ("answer.keyword": "UNHANDLED")

Required fields ( Questions & timestamp & aggregation count) & SIZE = 50 records needed

My timestamp is in epoch format and while displaying the records need to show in the date format.

Below is the query Tried

{

"query":{ "bool": { "must": { "term": { "answer.keyword": "UNHANDLED" } }, "must": { "term": { "source.keyword": "sonax" } } } }, "aggs": { "MyBuckets": { "terms": { "field": "question.keyword",”timestamp”, "sort":{ "_timestamp": "desc" "_source": { "includes": [ "source":"question.keyword",”timestamp”,

}, "size": "50" } } } }

Below is the errors:

  1. Duplicate Key must syntax error

enter image description here

Please check this: some synatx is missing

enter image description here

1
and what goes wrong when you run that query?Ryan Walker
Duplicate Key must syntax error. Please check the above screenshot. I think We need to modifiy the queryPrabhudas8703

1 Answers

1
votes

incorrect json, it will duplicate names because of the must. Please try:

{
   "query":{
      "bool":{
         "must":[
            {
               "term":{
                  "answer.keyword":"UNHANDLED"
               }
            },
            {
               "term":{
                  "source.keyword":"sonax"
               }
            }
         ]
      }
   }
}