0

I am new to AWS elasticsearch but need to create queries to search the follow data with different criteria.

  1. search_metadata (json string with key/value pair) - "{\"number\":\"111\"; \"area\":\"central\"; "\code\":\"1111\"; \"type\":\"internal\"}"
  2. category - "statement" or "bill" or "email"
  3. datetime - "2019-05-04T00:00:00" or "2019-07-16T00:01:00"
  4. flag - "good" or "bad"

I need to construct query to do the following

  1. AND or OR condition in search_metadata field (JSON string) -> not sure how to do it.
  2. along with AND condition for category, datetime range and flag. -> Do I need to use muliti-match for flag and category ?

       "query": {
       "bool": {
         "must": [
          {
            "match_phrase": {
              "search_metadata": "number 111"  --> not sure about AND or OR with "area" and others          
            }
          },     
         {
          "range": {
            "datetime": {
              "gte": "2019-05-04T00:00:00Z",
              "lte": "2019-07-16T00:01:00Z"
            }
           }
         }  
         ]
        }
       }
      }
    
user1747980
  • 245
  • 1
  • 4
  • 14

0 Answers0