0

I am trying to write a query, In which multiple values should get matched with the field.

In the example, I am trying to get results from all months with the matching field in the query. What I don't know is, how to write this query in dsl ?

months = [2,3,4]
client = Elasticsearch()
    s = Search(using=client, index="namco_revenuestream")
s = s.query("match", month_period=months)
Jinto Antony
  • 458
  • 8
  • 26

2 Answers2

0

You can use terms query instead of match query as below:

{
  "query": {
    "terms": {
      "month_period": [2,3,4]
    }
  }
}

EDIT: Query using match

{
  "query": {
    "match": {
      "month_period": {
        "query": "2 3 4",
        "analyzer": "standard"
      }
    }
  }
}
Nishant
  • 7,504
  • 1
  • 21
  • 34
0
q1 = Q("terms", phone=items)
Dave
  • 3,073
  • 7
  • 20
  • 33