# Find by query and push to array in Elastic search

**URL:** <https://discuss.elastic.co/t/find-by-query-and-push-to-array-in-elastic-search/123372>\
**Category:** Elasticsearch\
**Created:** [March 10, 2018, 6:29am UTC](https://discuss.elastic.co/t/find-by-query-and-push-to-array-in-elastic-search/123372 "2018-03-10T06:29:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohammad\_S07](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@mohammad\_S07](https://discuss.elastic.co/u/mohammad_S07)\
**Post date:** [March 10, 2018, 6:29am UTC](https://discuss.elastic.co/t/find-by-query-and-push-to-array-in-elastic-search/123372/1 "2018-03-10T06:29:23Z")

</div>

I store data in the elastic search like this:

```
{
"_index": "my_index",
"_type": "doc",
"_id": "6lDquGEBFRQVe0x93eHk",
"_version": 1,
"_score": 1,
"_source": {
"ID_Number": "6947503728601",
"Userrname":"Jack.m07",
"name": "Jack",
"photos": ["img/one.png"]
}
}

```

I want find user by ID\_Number and push new value to Photos

e.g)"photos": ["img/one.png","img/two.png"]

How can I implement this?what is the query?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 10, 2018, 7:23am UTC](https://discuss.elastic.co/t/find-by-query-and-push-to-array-in-elastic-search/123372/2 "2018-03-10T07:23:30Z")

</div>

What would be better is to use your id number as the \_id field as well.

In which case it will be super straight forward to send a new version of the document.

Otherwise you need to call the update by query API. But it's slower.

---

<div class="post-metadata">

**Author:** ![mohammad\_S07](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@mohammad\_S07](https://discuss.elastic.co/u/mohammad_S07)\
**Post date:** [March 11, 2018, 5:39am UTC](https://discuss.elastic.co/t/find-by-query-and-push-to-array-in-elastic-search/123372/3 "2018-03-11T05:39:17Z")

</div>

Thanks Dear @dadoonet it's very helpfull  
can you help me in an other problem?

> [@Search and get distenic result base on create\_at in elasticsearch](https://discuss.elastic.co/t/search-and-get-distenic-result-base-on-create-at-in-elasticsearch/123408):
>
> I store data in the Elasticsearch like this: { "\_index": "my\_index", "\_type": "doc", "\_id": "6lDquGEBFRQVe0x93eHk", "\_version": 1, "\_score": 1, "\_source": { "Barcode": "6947503728601", "category":"pen", "name": "panter", "price":"4$", "created\_at": "1519225855" } } Each data set has a barcode. For example, all panter pen have "6947503728601" as a barcode but they have different created\_at values. I want to search for partial barcode numbe…

---

<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:** [April 8, 2018, 5:39am UTC](https://discuss.elastic.co/t/find-by-query-and-push-to-array-in-elastic-search/123372/4 "2018-04-08T05:39:42Z")

</div>

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