# Term query by id or get api?

**URL:** <https://discuss.elastic.co/t/term-query-by-id-or-get-api/8216>\
**Category:** Elasticsearch\
**Created:** [June 25, 2012, 4:18pm UTC](https://discuss.elastic.co/t/term-query-by-id-or-get-api/8216 "2012-06-25T16:18:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ywtsang](https://avatars.discourse-cdn.com/v4/letter/y/a698b9/32.png) [@ywtsang](https://discuss.elastic.co/u/ywtsang)\
**Post date:** [June 25, 2012, 4:18pm UTC](https://discuss.elastic.co/t/term-query-by-id-or-get-api/8216/1 "2012-06-25T16:18:34Z")

</div>

If I want to retrieve documents by id, which one is preferred?

1. term query by id
2. get api

Provided that performance is the first priority and I do not need to  
retrieve by "real time", i.e. the freshness of the documents retrieved  
can be the same as normal search.

Get api seems to be more preferred as it can be specified as "local",  
but is the term query by id faster if the documents somehow is  
"cached" internally?

Thanks,  
Wing

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [June 25, 2012, 5:29pm UTC](https://discuss.elastic.co/t/term-query-by-id-or-get-api/8216/2 "2012-06-25T17:29:22Z")

</div>

On Tue, 2012-06-26 at 00:18 +0800, Yiu Wing TSANG wrote:

> If I want to retrieve documents by id, which one is preferred?
> 
> 1. term query by id
> 2. get api
> 
> Provided that performance is the first priority and I do not need to  
> retrieve by "real time", i.e. the freshness of the documents retrieved  
> can be the same as normal search.
> 
> Get api seems to be more preferred as it can be specified as "local",  
> but is the term query by id faster if the documents somehow is  
> "cached" internally?

The GET api will definitely be faster than the term query

clint

---

<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:** [July 6, 2017, 3:22am UTC](https://discuss.elastic.co/t/term-query-by-id-or-get-api/8216/3 "2017-07-06T03:22:37Z")

</div>


