Range query on integer fields

Hi all,

My mapping:

    {
        'doc': {
            'sources': {
                'properties': {
                     'depth': {
                         'type': 'integer'
                     }
                }
            }
        }
    }

I have docs like:

    {'sources': [{'depth': 0}, {'depth': 3}]}
    {'sources': [{'depth': 3}]}

My query:

    {
       "query": {
          "range": {
             "sources.depth": {
                "gt": 2
             }
          }
       }
    }

returns above 2 documents which is expected.

But, how should I create a query to return only the second one?
I mean is there some kind of mechanism in ES query that will return me the result of such conditions?

    {
       "query": {
          "must": {
              "range": {
                 "sources.depth": {
                    "gt": 2
                 }
             }
         },
          "must_not": {
              "range": {
                 "sources.depth": {
                    "lte": 2
                 }
             }
          }
       }
    }

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