Search on count of nested (child) documents


#1

Can I search for all documents with > N children?

Let's say I've got a social network with the following mapping:

{
  “users” : {
    “properties” : {
      “username” : {“type” : “string”, "index": "not_analyzed”},
      “full_name” : {“type” : “string”},
      “friends” : {
        “type” : “nested”,
        “properties” : {
          “username” : {“type” : “string”, "index": "not_analyzed”},
          “date_friended” : {“type” : “date”},
        }
      }
    } 
  }
}

Can I search for all users with > 5 friends? As of right now, I'm maintaining a separate count of the children in the parent document.

Thanks in advance!


#2

@Zach - Any luck regarding this? I have roughly the same question and found this old ask. Curious how to bump it back up to see if someone has any new ideas with ES 5.


(system) #3