Hello all, we are now query elasticsearch to get exactly documents which have ID should match one in the ID array. It's smiliar to the following SQL query:
SELECT * FROM myindex WHERE transaction_id IN (id1, id2, id3)
translate it to Elasticsearch Query:
{
"from": 0,
"size": 10000,
"query": {
"bool": {
"must": {
"bool": {
"should": [
{
"match": {
"transaction_id": {
"query": "a",
"type": "phrase"
}
}
},
{
"match": {
"transaction_id": {
"query": "b",
"type": "phrase"
}
}
},
{
"match": {
"transaction_id": {
"query": "c",
"type": "phrase"
}
}
}
]
}
}
}
}
}
However, with ~136 million document (continue growing) and size of the ID array is ~5000, this query come extremely slow.
Any suggestion to optimize this?

So what happens if there are many terms? Can you guide me to some resources about this?