1

I am new to elastic search and I need help for below scenario:

I have two fields tag and author. I want to search the data with condition

(tag="1" and (author="A" or author="B")) or (tag="2" and (author="A" or author="C")) or tag="3"

Please give a outline of how to frame the Elastic Search query.

wo de
  • 11
  • 1

1 Answers1

1

Use the query string query:

POST your-index/_search
{
  "query": {
    "query_string": {
      "query": "(tag:'1' AND author:('A' OR 'B')) OR (tag:'2' AND author:('A' OR 'C'))"
    }
  }
}
Joe - GMapsBook.com
  • 15,787
  • 4
  • 23
  • 68