How to search multiple fields and aggregate scores?

Hi all,

I'm trying to figure out a solution to how I should structure my queries for finding answers to people's questions. For example, based off the dataset I will paste at the end of this post, I would like to query "Shows about romance", and maybe get results like so:

{
  "hits": [
    {
      "_score": "31",
      "_source": {
        "anime": "Grisaia no Kajitsu"
      }
    },
    {
      "_score": "12",
      "_source": {
        "anime": "Mirai Nikki"
      }
    },
    {
      "_score": "7",
      "_source": {
        "anime": "Bakemonogatari"
      }
    }
  ]
}

Grisaia no Kajitsu shows up as the first result because it's shown in multiple relevant questions, and Mirai Nikki is second because it had a higher score than Bakemonogatari.

Basically I would like answers that are relevant based off the question, score, and tags field. Questions that have repeated answers should have a higher score. Any suggestions? Below is an example of my dataset:

[
  {
    "question": "Looking for romance anime",
    "score": 4,
    "answers": [
      {
        "anime": "Mirai Nikki",
        "score": 8,
        "tags": ["action", "adventure", "death game", "romance"]
      },
      {
        "anime": "Bakemonogatari",
        "score": 3,
        "tags": ["action", "comedy", "romance", "seinen"]
      }
    ]
  },
  {
    "question": "Survival Anime",
    "score": 10,
    "answers": [
      {
        "anime": "Grisaia no Kajitsu",
        "score": 4,
        "tags": ["school", "drama", "survival", "romance"]
      },
      {
        "anime": "Kanata no Astra",
        "score": 7,
        "tags": ["action", "comedy", "drama", "space"]
      }
    ]
  },
  {
    "question": "Horror and romance anime?",
    "score": 12,
    "answers": [
      {
        "anime": "Grisaia no Kajitsu",
        "score": 15,
        "tags": ["school", "drama", "survival", "romance"]
      }
    ]
  }
]

Thanks!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.