Difference between queries


#1
  1. "query": {
    "range": { createTime: { "gte": "1483142400000" } }
    }

  2. "filtered": {
    "query": {
    "match_all": {}
    },
    "filter":
    { "range": { "createTime": { "gte": "1483142400000" }}}
    }
    }

  3. Can you please let me know what is the difference between two queries?

  4. If the output of both queries are same can you please let me know which query executes faster?

  5. Is there a better way to write this query?


(David Pilato) #2

As you seem using an old version, the second might be faster.

In 6.x, you will have to use a bool query with a filter clause.


#3

Thanks @dadoonet. We are using es 2.4. Why is the second query better than the first?


(David Pilato) #4

It does not participate to scoring and can be cached then.


#5

We are planning to use this query for re-indexing purpose (used in the source indices to filter data). So, caching will not help. Do you still think the second query is better?


(David Pilato) #6

Yes. I still think it.


(system) #7

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