I have built the below query in python with ElasticSearch library loaded.
I’d like to keep expanding the list below so I can find the corresponding data for the ones within the list.
How do I pass the “list” into the ElasticSearch query so later I can just keep expanding the “list” once I need to add more (like hundreds) into my search list?
JavaScript
x
12
12
1
list = ["123","234","456"]
2
3
query_all = {
4
"query": {
5
"bool":{
6
"must":[
7
{"match": {"orderData.orderId.id.keyword" : list}},
8
]
9
}
10
}
11
}
12
Advertisement
Answer
Probably you are looking for terms query
JavaScript
1
14
14
1
{
2
"query": {
3
"bool": {
4
"must": [
5
{
6
"terms": {
7
"orderData.orderId.id.keyword": list
8
}
9
}
10
]
11
}
12
}
13
}
14