Difference between queries

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

  2. "filtered": {
    "query": {
    "match_all": {}
    { "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?

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.

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

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

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?

Yes. I still think it.

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