# Prefix Query on Custom \_id Field

**URL:** <https://discuss.elastic.co/t/prefix-query-on-custom-id-field/234226>\
**Category:** Elasticsearch\
**Created:** [May 26, 2020, 1:52am UTC](https://discuss.elastic.co/t/prefix-query-on-custom-id-field/234226 "2020-05-26T01:52:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheTechromancer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thetechromancer/32/69041_2.png) [@TheTechromancer](https://discuss.elastic.co/u/TheTechromancer)\
**Post date:** [May 26, 2020, 1:52am UTC](https://discuss.elastic.co/t/prefix-query-on-custom-id-field/234226/1 "2020-05-26T01:52:06Z")

</div>

Greetings,

I am looking for a way to perform a prefix query on **\_id** without duplicating its value to another field. I am overriding \_id with a custom string value as a "primary key" to prevent duplicates. Is it possible to redefine the mappings for the \_id field to allow for this type of query?

```auto
{
    'query': {
        'prefix': {
            '_id': 'deadbeef'
        }
    }
}

```

The error I'm receiving:

```auto
Can only use prefix queries on keyword and text fields - not on [_id] which is of type [_id]

```

Development is still in early stages so I'm still free to change how this works, I just need to keep storage requirements to a minimum. Thanks!

---

<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 23, 2020, 1:52am UTC](https://discuss.elastic.co/t/prefix-query-on-custom-id-field/234226/2 "2020-06-23T01:52:17Z")

</div>

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