# Getting all documents in Elastic Search Shard

**URL:** <https://discuss.elastic.co/t/getting-all-documents-in-elastic-search-shard/254690>\
**Category:** Elasticsearch\
**Created:** [November 8, 2020, 7:41pm UTC](https://discuss.elastic.co/t/getting-all-documents-in-elastic-search-shard/254690 "2020-11-08T19:41:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![asagarwal10](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asagarwal10/32/78646_2.png) [@asagarwal10](https://discuss.elastic.co/u/asagarwal10)\
**Post date:** [November 8, 2020, 7:41pm UTC](https://discuss.elastic.co/t/getting-all-documents-in-elastic-search-shard/254690/1 "2020-11-08T19:41:31Z")

</div>

I am trying to get all documents in a shard.

When creating the index, I used the query:

```auto
PUT mortgages-stage
{
  "mappings": {
    "_routing": {
      "required": true
    }
  }
}

```

When adding documents to the index, I used the user's id as the routing parameter. I can see that the documents in elasticsearch have the `_routing` parameter set for all documents and it has been correctly set as the user's id.

Example of a document:

```auto
{
  "_index" : "mortgages-stage",
  "_type" : "_doc",
  "_id" : "841966e1-ef66-4e19-8d8a-1e0f6b075aa2-CLFFI-3451",
  "_score" : 1.0,
  "_routing" : "841966e1-ef66-4e19-8d8a-1e0f6b075aa2",
  "_source" : {
      "LastModifiedOn" : "2020-11-08T11:05:21Z-0800",
       "ID" : "841966e1-ef66-4e19-8d8a-1e0f6b075aa2-CLFFI-3451",
      "UserID" : "841966e1-ef66-4e19-8d8a-1e0f6b075aa2",
   }
}

```

I am trying to fetch all documents in a shard using the query:  
`GET /mortgages-stage/_search?routing=254b2796-9be4-4704-b756-6fe2e3e80f36`

However, this query returns all the documents in the index rather than the documents in the shard id: `254b2796-9be4-4704-b756-6fe2e3e80f36`. How do I figure out what's wrong?

---

<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 6, 2020, 7:41pm UTC](https://discuss.elastic.co/t/getting-all-documents-in-elastic-search-shard/254690/2 "2020-12-06T19:41:32Z")

</div>

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