# Search Query Based on Nested Fields

**URL:** <https://discuss.elastic.co/t/search-query-based-on-nested-fields/333084>\
**Category:** Elasticsearch\
**Created:** [May 10, 2023, 12:51pm UTC](https://discuss.elastic.co/t/search-query-based-on-nested-fields/333084 "2023-05-10T12:51:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mustafa\_AYDOGDU](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mustafa_aydogdu/32/119908_2.png) [@Mustafa\_AYDOGDU](https://discuss.elastic.co/u/Mustafa_AYDOGDU)\
**Post date:** [May 10, 2023, 12:51pm UTC](https://discuss.elastic.co/t/search-query-based-on-nested-fields/333084/1 "2023-05-10T12:51:49Z")

</div>

I have this kind of data:

```auto
"1655184519597531137": {
            "reply_depth": 1,
            "gather_likes": false,
            "gather_user_data": "false",
            "keyword": "galatasaray",
            "gather_retweets": false,
            "user_id": "Hatice_GS1905"
          },
          "@version": "1",
          "@timestamp": "2023-05-07T13:42:26.252138737Z",
          "1655160784605913090": {
            "reply_depth": 1,
            "gather_likes": false,
            "gather_user_data": "false",
            "keyword": "galatasaray",
            "gather_retweets": false,
            "user_id": "MrEnnyG"
          },
          "1655171782498713601": {
            "reply_depth": 1,
            "gather_likes": false,
            "gather_user_data": "false",
            "keyword": "galatasaray",
            "gather_retweets": false,
            "user_id": "salvareyiz"
          },

```

I want to find the number of data whose keyword=galatasaray. How can I do that? Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 10, 2023, 12:55pm UTC](https://discuss.elastic.co/t/search-query-based-on-nested-fields/333084/2 "2023-05-10T12:55:43Z")

</div>

> [@Mustafa\_AYDOGDU](#):
>
> `"1655160784605913090": {`

This looks like a field name that represents a timestamp in nanoseconds. If this is the case it is very bad and will result in mapping explosion. If this is indeed the case I would recommend you change how you index data.

---

<div class="post-metadata">

**Author:** ![Mustafa\_AYDOGDU](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mustafa_aydogdu/32/119908_2.png) [@Mustafa\_AYDOGDU](https://discuss.elastic.co/u/Mustafa_AYDOGDU)\
**Post date:** [May 10, 2023, 12:56pm UTC](https://discuss.elastic.co/t/search-query-based-on-nested-fields/333084/3 "2023-05-10T12:56:25Z")

</div>

It is tweet id, not timestamp actually.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 10, 2023, 12:58pm UTC](https://discuss.elastic.co/t/search-query-based-on-nested-fields/333084/4 "2023-05-10T12:58:59Z")

</div>

That is still likely to grow almost linearly over time so is still very bad. You will hit system limits and if you just increase these as a workaround the cluster will eventually grind to a halt. It would be better to move it into a field, e.g. `"tweet_id": "1655160784605913090"`. I suspect this would also solve your query problem as you would then know the full path of the field to query.

---

<div class="post-metadata">

**Author:** ![Mustafa\_AYDOGDU](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mustafa_aydogdu/32/119908_2.png) [@Mustafa\_AYDOGDU](https://discuss.elastic.co/u/Mustafa_AYDOGDU)\
**Post date:** [May 10, 2023, 1:04pm UTC](https://discuss.elastic.co/t/search-query-based-on-nested-fields/333084/5 "2023-05-10T13:04:01Z")

</div>

Yes, you are absolutely right. Thank you so much!

---

<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 7, 2023, 1:04pm UTC](https://discuss.elastic.co/t/search-query-based-on-nested-fields/333084/6 "2023-06-07T13:04:29Z")

</div>

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