# Elasticsearch find which field and array index matched?

**URL:** <https://discuss.elastic.co/t/elasticsearch-find-which-field-and-array-index-matched/212581>\
**Category:** Elasticsearch\
**Created:** [December 20, 2019, 1:32am UTC](https://discuss.elastic.co/t/elasticsearch-find-which-field-and-array-index-matched/212581 "2019-12-20T01:32:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cjsjyh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjsjyh/32/59845_2.png) [@cjsjyh](https://discuss.elastic.co/u/cjsjyh)\
**Post date:** [December 20, 2019, 1:32am UTC](https://discuss.elastic.co/t/elasticsearch-find-which-field-and-array-index-matched/212581/1 "2019-12-20T01:32:15Z")

</div>

I am currently using `multi_match` to search nested datatypes.

I want to find the index of `shortreview` which matched my query.  
For example, if query matched `""" review_ccc """` of my `review` field, return 2.

my purpose is to find `reviewId` of `shortreview` or `review`. Because `reviewId` will be placed in the same order with `shortreview` and `review`, I need to find the index of the match.

```auto
GET recpost_test/_search
{
  "from": 0,
  "size": 2,
  "query":{
    "multi_match": {
      "query" : "This is what I want to find!",
      "analyzer": "my_analyzer", 
      "type": "best_fields", 
      "fields" : [
        "itemname",
        "review",
        "shortreview^2"]
        
    }
  }
}

```

Here's the simplified version of query result

```auto
{
  "took" : 12,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 58,
      "relation" : "eq"
    },
    "max_score" : 19.384338,
    "hits" : [
      {
        "_index" : "recpost_test",
        "_type" : "_doc",
        "_id" : "202",
        "_score" : 19.384338,
        "_source" : {
          "reviewId" : [
            "1",
            "2",
            "3"
          ],
          "review" : [
            """ review_aaa """,
            """ review_bbb """,
            """ review_ccc """
          ],
          "shortreview" : [
            """ shortreview_aaa """,
            """ shortreview_bbb """,
            """ shortreview_ccc """
          ],
          "itemname" : [
            "item_a",
            "item_b",
            "item_c"
          ]
        }
      }
    ]
  }
}

```

---

<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 17, 2020, 1:32am UTC](https://discuss.elastic.co/t/elasticsearch-find-which-field-and-array-index-matched/212581/2 "2020-01-17T01:32:29Z")

</div>

Closed on January 17, 2020, 1:32am UTC

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