# Search by an incomplete id

**URL:** <https://discuss.elastic.co/t/search-by-an-incomplete-id/288297>\
**Category:** Elastic Search\
**Created:** [November 3, 2021, 8:14am UTC](https://discuss.elastic.co/t/search-by-an-incomplete-id/288297 "2021-11-03T08:14:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ntruongsinh](https://avatars.discourse-cdn.com/v4/letter/n/8c91f0/32.png) [@ntruongsinh](https://discuss.elastic.co/u/ntruongsinh)\
**Post date:** [November 3, 2021, 8:14am UTC](https://discuss.elastic.co/t/search-by-an-incomplete-id/288297/1 "2021-11-03T08:14:12Z")

</div>

Hi all,  
I have a document with the id `abc` and the requirement that when user search by `ab`, it should return my document.  
Currently, after I check Elasticsearch to see how appsearch indexes the document. I recoginize that the id field is diffrent from other fields, it's just stored as keyword.

```auto
"id": {
    "type": "keyword"
},

```

It means that when we want to search by id, we have to put an exact id (`abc` in my case), we could not search by `ab` or something similar.  
So I'm thinking that I will store another field having the same value of the id field (because the id is generated by the app) to fulfill the requirement.  
However, I wonder if we have another simpler solution for it?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [November 3, 2021, 3:38pm UTC](https://discuss.elastic.co/t/search-by-an-incomplete-id/288297/2 "2021-11-03T15:38:16Z")

</div>

> [@ntruongsinh](#):
>
> So I'm thinking that I will store another field having the same value of the id field (because the id is generated by the app) to fulfill the requirement.

This is what I would suggest.

---

<div class="post-metadata">

**Author:** ![ntruongsinh](https://avatars.discourse-cdn.com/v4/letter/n/8c91f0/32.png) [@ntruongsinh](https://discuss.elastic.co/u/ntruongsinh)\
**Post date:** [November 3, 2021, 6:02pm UTC](https://discuss.elastic.co/t/search-by-an-incomplete-id/288297/3 "2021-11-03T18:02:32Z")

</div>

Thanks, @JasonStoltz .

---

<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 4, 2022, 8:32am UTC](https://discuss.elastic.co/t/search-by-an-incomplete-id/288297/4 "2022-11-04T08:32:55Z")

</div>


