# Can I get only those parts of array during a search which match the result?

**URL:** <https://discuss.elastic.co/t/can-i-get-only-those-parts-of-array-during-a-search-which-match-the-result/108444>\
**Category:** Elasticsearch\
**Created:** [November 20, 2017, 6:50pm UTC](https://discuss.elastic.co/t/can-i-get-only-those-parts-of-array-during-a-search-which-match-the-result/108444 "2017-11-20T18:50:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jalaj](https://avatars.discourse-cdn.com/v4/letter/j/e79b87/32.png) [@jalaj](https://discuss.elastic.co/u/jalaj)\
**Post date:** [November 20, 2017, 6:50pm UTC](https://discuss.elastic.co/t/can-i-get-only-those-parts-of-array-during-a-search-which-match-the-result/108444/1 "2017-11-20T18:50:16Z")

</div>

I have document similar to below

```
POST /index1/test
{
  "user":"u1",
  "tags":[1,2,3,4,5,6,7,8]
}

```

The following search is executed and it returns the entire tag attribute. Can I only get the elements it matched i.e 1and 2 only ?

```
  GET /index1/test/_search
    {
      "query": {
        "terms": {
          "tags": [
            1,
            2
          ]
        }
      }
    }
```

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [November 21, 2017, 2:01pm UTC](https://discuss.elastic.co/t/can-i-get-only-those-parts-of-array-during-a-search-which-match-the-result/108444/2 "2017-11-21T14:01:07Z")

</div>

No, this is impossible.

---

<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:** [December 19, 2017, 2:05pm UTC](https://discuss.elastic.co/t/can-i-get-only-those-parts-of-array-during-a-search-which-match-the-result/108444/3 "2017-12-19T14:05:54Z")

</div>

Closed on December 19, 2017, 2:05pm UTC

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