Using missing and exists fliter together in single query

I am trying to get a query which can return a json which satisfies both
conditions of a filtering. I am trying to get a response which has feed
containing one field named "test1" and it should also be missing a field
"test2", Ive tried the query

{
 "query": {
  "filtered": {
  "query": {
    "match_all": {}
   },
      "filter": {
         "missing": {
        "field": "test2"
       },
       "exists": {
         "field": "test1"
       }
      }
    }
  } 
}

The above query returns all the fields which has the field "test1" and it
also returns feeds which are missing field "test2", I am trying to narrow
down the response as I only want feeds satisfying both conditions. It would
be appreciated if anyone could tell me what my mistake is..

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hey,

can you try this and see if it works for you

    "filtered" : {
        "query" : { "match_all" : {} },
        "filter" : {
            "and": [
                { "missing" : { "field" : "c" } },
                { "exists" : { "field" : "a" } }
            ]
        }
    }

--Alex

On Thu, Apr 11, 2013 at 2:18 PM, shyamr@algotree.com wrote:

elasticsearch - Using missing and exists filter together in single query - Stack Overflow

I am trying to get a query which can return a json which satisfies both
conditions of a filtering. I am trying to get a response which has feed
containing one field named "test1" and it should also be missing a field
"test2", Ive tried the query

{
 "query": {
  "filtered": {
  "query": {
    "match_all": {}
   },
      "filter": {
         "missing": {
        "field": "test2"
       },
       "exists": {
         "field": "test1"
       }
      }
    }
  }
}

The above query returns all the fields which has the field "test1" and it
also returns feeds which are missing field "test2", I am trying to narrow
down the response as I only want feeds satisfying both conditions. It would
be appreciated if anyone could tell me what my mistake is..

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.