# Difference between \`terms\` and \`term\` query for a single term?

**URL:** https://discuss.elastic.co/t/difference-between-terms-and-term-query-for-a-single-term/373248
**Category:** Elasticsearch
**Created:** [January 15, 2025, 7:15pm UTC](https://discuss.elastic.co/t/difference-between-terms-and-term-query-for-a-single-term/373248 "2025-01-15T19:15:20Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![yeikel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yeikel/32/125434_2.png) [@yeikel](https://discuss.elastic.co/u/yeikel)
#### Post date: [January 15, 2025, 7:15pm UTC](https://discuss.elastic.co/t/difference-between-terms-and-term-query-for-a-single-term/373248/1 "2025-01-15T19:15:20Z")

</div>

Is there any significant implementation difference between `terms` and `term` query when there is a single term to search?

In a situation where I know the number of terms in advance, is it worth it to implement them separately?  
Ie:

```auto
 if tokens > 1 
     buildTermsQuery
else
   buildTermQuery

```

Does a `terms` query with a single term have any penalty?

Based on what I was able to gather from the query profiler, there seems to be a difference as the `Terms` query uses a `MultiTermQueryConstantScoreBlendedWrapper` while the `Term` query uses `TermQuery` directly. I just wonder if it ultimately matters

---

<div class="post-metadata">

### Author: ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)
#### Post date: [January 15, 2025, 7:56pm UTC](https://discuss.elastic.co/t/difference-between-terms-and-term-query-for-a-single-term/373248/2 "2025-01-15T19:56:13Z")

</div>

Hi @yeikel

"Giving my two cents", I believe that the performance impact of using terms for a single term would be negligible, even though terms requires the term to go through the list processing flow, as per its default operation. What is really worth paying attention to is correctly mapping the field, ensuring that it is suitable for term-level queries, such as term and terms. Proper mapping, such as using keyword fields, is essential for the proper functioning of these queries.

---

<div class="post-metadata">

### Author: ![yeikel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yeikel/32/125434_2.png) [@yeikel](https://discuss.elastic.co/u/yeikel)
#### Post date: [January 15, 2025, 8:06pm UTC](https://discuss.elastic.co/t/difference-between-terms-and-term-query-for-a-single-term/373248/3 "2025-01-15T20:06:27Z")

</div>

> [@RabBit\_BR](#):
>
> "Giving my two cents", I believe that the performance impact of using terms for a single term would be negligible, even though terms requires the term to go through the list processing flow, as per its default operation. What is really worth paying attention to is correctly mapping the field, ensuring that it is suitable for term-level queries, such as term and terms. Proper mapping, such as using keyword fields, is essential for the proper functioning of these queries.

Thanks for the input. That's understandable. We are using `keyword` already 🙂

I am just curious as to why both exist because in theory they could just implement `Term` using `Terms` with a single term?

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [January 16, 2025, 2:51am UTC](https://discuss.elastic.co/t/difference-between-terms-and-term-query-for-a-single-term/373248/4 "2025-01-16T02:51:47Z")

</div>

> [@yeikel](#):
>
> I am just curious as to why both exist because in theory they could just implement `Term` using `Terms` with a single term?

It's a convenience function ...instead of `bool` `should` `term`

---

<div class="post-metadata">

### Author: ![yeikel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yeikel/32/125434_2.png) [@yeikel](https://discuss.elastic.co/u/yeikel)
#### Post date: [January 17, 2025, 4:29am UTC](https://discuss.elastic.co/t/difference-between-terms-and-term-query-for-a-single-term/373248/5 "2025-01-17T04:29:30Z")

</div>

> It's a convenience function ...instead of `bool` `should` `term`

`MultiTermQueryConstantScoreBlendedWrapper` seems to be doing quite a bit of work, that's where my main question started

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [January 17, 2025, 5:00am UTC](https://discuss.elastic.co/t/difference-between-terms-and-term-query-for-a-single-term/373248/6 "2025-01-17T05:00:39Z")

</div>

From the docs

> **[Terms query | Elasticsearch Guide \[8.17\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html)**

> The terms query is the same as the term query, except you can search for multiple values. A document will match if it contains at least one of the terms. To search for documents that contain more than one matching term, use the terms\_set query.
