I have two documents, both (should) have a parent (different parents, but 
the same type).

However, I don't get the result I expect - especially trying to return 
documents *without* a parent.

For example:

{
  "fields":["_parent"],
  "query": {
    "filtered": {
      "query": {
        "query_string": {
          "query": "kittens*"
        }
      },
      "filter": {
        "bool": {
          "must_not": [
            {
              "has_parent": {
                "parent_type": "psa",
                "query": {
                  "match_all": {}
                }
              }
            }
          ]
        }
      }
    }
  }
}

I run that, and I get this back:

{
   "took": 287,
   "timed_out": false,
   "_shards": {
      "total": 1,
      "successful": 1,
      "failed": 0
   },
   "hits": {
      "total": 1,
      "max_score": 1,
      "hits": [
         {
            "_index": "egroup",
            "_type": "document",
            "_id": "6_9104",
            "_score": 1,
            "fields": {
               "_parent": "6_905"
            }
         }
      ]
   }
}


Clearly it DOES have a parent because it shows in the results!

If I change the initial query from "must_not" to "must", I get the other 
document in the result:

{
   "took": 75,
   "timed_out": false,
   "_shards": {
      "total": 1,
      "successful": 1,
      "failed": 0
   },
   "hits": {
      "total": 1,
      "max_score": 1,
      "hits": [
         {
            "_index": "egroup",
            "_type": "document",
            "_id": "6_9106",
            "_score": 1,
            "fields": {
               "_parent": "6_847"
            }
         }
      ]
   }
}

One query should return zero results, and the other should return 2. 
However each are returning 1.

Am I being thick, or is something amiss here - and how can I troubleshoot 
it?


Tom.


-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/c8beeddf-2cfb-4af7-8836-6779baf85933%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to