Execution plan for es search?


(famoss) #1

If i have a query:

"query": {
    "bool": {
        "filter": [
            {
                "term": {
                    "field1": "f1"
                }
            },
            {
                "range": {
                    "field3": {
                        "gt": "1"
                    }
                }
            }
        ]
    }
}

The query has two query item,es will create two thread(each thread just execute one query item),and merge result in the end?

Or,es will execute two query item one by one,for example term "field1":"f1" just get 100 documents,and then range field3 gt 1 just filter in the 100 documents instead of all documents?


(Daniel Mitterdorfer) #2

Hi @famoss,

each query is processed by a single thread (per shard). See the Definitive Guide on an in-depth explanation of what's going on under the cover.

Daniel


(Mark Walkom) #3

Also please do not PM people to get answers to your threads.

If you need answers quickly then there are commercial subscriptions to assist you.


(famoss) #4

Thank you.Because there is just one thread to execute one query,so i should be care of the filter order?

For example, just as the question,if condition 1 just get 100 documents,and condition 2 can get 1000000 documents,i should place condition 1 before condition 2?


(famoss) #5

I'm very sorry


(David Pilato) #6

In recent versions of elasticsearch we take care of this internally and we run fastest filters first.
In old versions, yes, order was super important.


(famoss) #7

In old versions, yes, order was super important

From which version? from v2+?


(David Pilato) #8

IIRC yes.


(system) #9

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.