# How to search multiple fields and aggregate scores?

**URL:** <https://discuss.elastic.co/t/how-to-search-multiple-fields-and-aggregate-scores/259659>\
**Category:** Elasticsearch\
**Created:** [December 26, 2020, 11:34am UTC](https://discuss.elastic.co/t/how-to-search-multiple-fields-and-aggregate-scores/259659 "2020-12-26T11:34:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shuri](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@Shuri](https://discuss.elastic.co/u/Shuri)\
**Post date:** [December 26, 2020, 11:34am UTC](https://discuss.elastic.co/t/how-to-search-multiple-fields-and-aggregate-scores/259659/1 "2020-12-26T11:34:28Z")

</div>

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:

```json
{
  "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:

```json
[
  {
    "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!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 23, 2021, 11:34am UTC](https://discuss.elastic.co/t/how-to-search-multiple-fields-and-aggregate-scores/259659/2 "2021-01-23T11:34:46Z")

</div>

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