Getting ElasticSearch to score number of total nested hits across results (idf?) higher than tf of single hit?
===

Forgive me if I'm munging the terminology, but I am having problems getting ES to score results in a way that makes sense for my app.

I am indexing thousands of Users with several simple fields, as well as potentially hundreds of child objects nested in the index for each user (i.e. the **Book** --> **Pages** data model). The JSON getting sent to the index looks like this:

    user_id: 1
      full_name: First User
      username: firstymcfirsterton
      posts: 
       id: 2
        title: Puppies are Awesome
        tags:
         - dog house
         - dog supplies
         - dogs
         - doggies
         - hot dogs
         - dog lovers

    user_id: 2
      full_name: Second User
      username: seconddude
      posts: 
       id: 3
        title: Dogs are the best
        tags:
         - dog supperiority
         - dog
       id: 4
        title: Why dogs eat?
        tags: 
         - dog diet
         - canines
       id: 5
        title: Who let the dogs out?
        tags:
         - dogs
         - terrible music

The tags are type "tags", using the "keyword" analyzer, and boosted 10. Titles are not boosted.

When I do a search for "dog", the first user has a higher score than the second user. I assume this has to do the with the tf-idf of the first user being higher. However in my app, the more posts a user that have a hit for the term ideally would come first.

I tried sorting by the number of posts, but this give junk results if the user has a lot of posts. Basically I want to sort by number of unique post hits, such that a user who has more posts that have hits will rise to the top.

How would I go about doing this. Any ideas?
