# Search large amounts of data as quickly as possible

**URL:** <https://discuss.elastic.co/t/search-large-amounts-of-data-as-quickly-as-possible/304021>\
**Category:** Elasticsearch\
**Created:** [May 5, 2022, 11:02am UTC](https://discuss.elastic.co/t/search-large-amounts-of-data-as-quickly-as-possible/304021 "2022-05-05T11:02:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![error\_701](https://avatars.discourse-cdn.com/v4/letter/e/f4b2a3/32.png) [@error\_701](https://discuss.elastic.co/u/error_701)\
**Post date:** [May 5, 2022, 11:02am UTC](https://discuss.elastic.co/t/search-large-amounts-of-data-as-quickly-as-possible/304021/1 "2022-05-05T11:02:23Z")

</div>

hey,  
i think i need ur help:

the following use case: Monitor IDS,  
I receive about 300 million records of IP addresses every day,  
I need to search them for every single unique IP address as the last entry. (event)

My previous attempt ended with the following query;

```auto
{    
    "track_total_hits": true,
    "size": 0,
    "query": {
    "term": {
            "ip.keyword": "123456789"
        }
    }, 
    "sort": { "@timestamp": "desc"},
    "aggs": {.
                "top_group_hits": {.
                    "top_hits": {.
                        "sort": [
                            {
                                "@timestamp": {
                                    "order": { "desc".
                                }
                            }
                        ],
                        }, "size": 1
                    }
                }
    
    }
    }

```

From the query duration this is a disaster, do you have any suggestions for improvement?

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [May 5, 2022, 1:48pm UTC](https://discuss.elastic.co/t/search-large-amounts-of-data-as-quickly-as-possible/304021/2 "2022-05-05T13:48:05Z")

</div>

Hi @error_701 Welcome to the community.

Perhaps you should look at creating a latest transform with the IP address as the unique key.

This will create an index that keep only the last entry for each unique IP.

> **[Transform overview | Elasticsearch Guide \[8.2\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/8.2/transform-overview.html#latest-transform-overview)**

Just a thought.. just did the same for big volume logs based on the host.name

---

<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 2, 2022, 1:48pm UTC](https://discuss.elastic.co/t/search-large-amounts-of-data-as-quickly-as-possible/304021/3 "2022-06-02T13:48:32Z")

</div>

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