1

Take the following Author example object (jsonified):

{
  "name": "Author 1",
  "enabled": true,
  "books": [
     {"name": "book1", "popular": true},
     {"name": "book2", "popular": true},
     {"name": "book3", "popular": false}
  ]
}

What I want, is to rank Authors based on how many popular books they have.

Currently, I'm doing the following query:

{
    "query": {
        "bool": {
            "filter": {
              "term": {"enabled": true}
            },
            "should": {
                "terms": {
                    "books.popular": [true]
                    "boost": 3
                }
           }
        }
    }
}

It works just fine, but it gives a 3 score boost if any book is popular (I think?).

How can I instead boost by how many popular books they have?

Mojimi
  • 2,561
  • 9
  • 52
  • 116

0 Answers0