# How to get score based on the matched field value in multi match (cross\_fields)

**URL:** <https://discuss.elastic.co/t/how-to-get-score-based-on-the-matched-field-value-in-multi-match-cross-fields/233644>\
**Category:** Elasticsearch\
**Created:** [May 21, 2020, 1:48am UTC](https://discuss.elastic.co/t/how-to-get-score-based-on-the-matched-field-value-in-multi-match-cross-fields/233644 "2020-05-21T01:48:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sangmin\_Lee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sangmin_lee/32/45032_2.png) [@Sangmin\_Lee](https://discuss.elastic.co/u/Sangmin_Lee)\
**Post date:** [May 21, 2020, 1:48am UTC](https://discuss.elastic.co/t/how-to-get-score-based-on-the-matched-field-value-in-multi-match-cross-fields/233644/1 "2020-05-21T01:48:06Z")

</div>

Hi !  
I'm looking for the way to get score based on the matched field value in the query of cross field in multi match.

This is how one of my index field looks like,

```auto
    "field_with_value" : [
                {
                  "name" : "Liam",
                  "value" : 15
                },
                {
                  "name" : "Jake",
                  "value" : 19
                },
                {
                  "name" : "Pall",
                  "value": 7
                }
              ],

```

And this is how my simplified version of the query looks like,

```auto
    {
      "query": {
        "script_score": {
          "query": {
            "bool": {
              "must": [
                {
                  "multi_match": {
                    "query": "Kind Liam",
                    "type": "cross_fields",
                    "fields": [
                      "field_A.name",
                      "field_B.name",
                      "field_with_value.name"
                    ],
                    "operator": "and"
                  }
                }
              ],
              "filter": [...]
            }
          },
          "script": {...}
        }
      }
    }

```

When field\_with\_value matched, how can I get the score using the 'value' of the matched field\_with\_value of the document?

Thanks for reading it!  
I'll be waiting for your help 😃

---

<div class="post-metadata">

**Author:** ![Sangmin\_Lee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sangmin_lee/32/45032_2.png) [@Sangmin\_Lee](https://discuss.elastic.co/u/Sangmin_Lee)\
**Post date:** [May 26, 2020, 10:54am UTC](https://discuss.elastic.co/t/how-to-get-score-based-on-the-matched-field-value-in-multi-match-cross-fields/233644/2 "2020-05-26T10:54:16Z")

</div>

For those who need it later,  
I solved it from [here](https://stackoverflow.com/questions/61952303/how-to-get-matched-field-value-of-array-field-using-painless-script-in-elasticse) [Stackoverflow]

---

<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:** [June 23, 2020, 10:54am UTC](https://discuss.elastic.co/t/how-to-get-score-based-on-the-matched-field-value-in-multi-match-cross-fields/233644/3 "2020-06-23T10:54:17Z")

</div>

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