# Query an Elasticsearch index for one field, all documents in last 24 hours?

**URL:** <https://discuss.elastic.co/t/query-an-elasticsearch-index-for-one-field-all-documents-in-last-24-hours/344493>\
**Category:** Elasticsearch\
**Created:** [October 5, 2023, 1:57pm UTC](https://discuss.elastic.co/t/query-an-elasticsearch-index-for-one-field-all-documents-in-last-24-hours/344493 "2023-10-05T13:57:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Meme-ento](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@Meme-ento](https://discuss.elastic.co/u/Meme-ento)\
**Post date:** [October 5, 2023, 1:57pm UTC](https://discuss.elastic.co/t/query-an-elasticsearch-index-for-one-field-all-documents-in-last-24-hours/344493/1 "2023-10-05T13:57:37Z")

</div>

Hi There.

I'm trying to make a simple get request to my elk index.  
I have the right credentials, hostname, index name, etc.  
my ELK version is 6.8.6

But for what I'm trying to get I cannot figure out how to construct the GET.

I'm only trying to get 1 field. For all documents in the last 24 hour period.

Any advice I would take, or resources on how to actually form these queries to get this index data.

---

<div class="post-metadata">

**Author:** ![PodarcisMuralis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/podarcismuralis/32/122606_2.png) [@PodarcisMuralis](https://discuss.elastic.co/u/PodarcisMuralis)\
**Post date:** [October 5, 2023, 7:40pm UTC](https://discuss.elastic.co/t/query-an-elasticsearch-index-for-one-field-all-documents-in-last-24-hours/344493/2 "2023-10-05T19:40:16Z")

</div>

```auto
GET /<index_name>/_search
{
  "query": {
    "range": {
      "@timestamp": {
        "gte": "now-24h",
        "lte": "now"
      }
    }
  },
  "fields": ["<field_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:** [November 2, 2023, 7:40pm UTC](https://discuss.elastic.co/t/query-an-elasticsearch-index-for-one-field-all-documents-in-last-24-hours/344493/3 "2023-11-02T19:40:52Z")

</div>

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