# Term query vs match query

**URL:** <https://discuss.elastic.co/t/term-query-vs-match-query/14455>\
**Category:** Elasticsearch\
**Created:** [November 19, 2013, 1:11am UTC](https://discuss.elastic.co/t/term-query-vs-match-query/14455 "2013-11-19T01:11:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohit\_Anchlia](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@Mohit\_Anchlia](https://discuss.elastic.co/u/Mohit_Anchlia)\
**Post date:** [November 19, 2013, 1:11am UTC](https://discuss.elastic.co/t/term-query-vs-match-query/14455/1 "2013-11-19T01:11:42Z")

</div>

Could somebody help me understand the difference between a term query and a  
match query? I saw the explanation on the elasticsearch site but couldn't  
quite follow. Isn't search always trying to match terms?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [November 19, 2013, 1:14am UTC](https://discuss.elastic.co/t/term-query-vs-match-query/14455/2 "2013-11-19T01:14:49Z")

</div>

The match query analyzes the input string and constructs more basic queries  
from that.

The term query matches exact terms.

If you have a document containing "CAT" and search for "cat" the match  
query will find it but the term query won't. That is, if you lowercase in  
your analysis config which it does by default.

On Mon, Nov 18, 2013 at 8:11 PM, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com)wrote:

> Could somebody help me understand the difference between a term query and  
> a match query? I saw the explanation on the elasticsearch site but couldn't  
> quite follow. Isn't search always trying to match terms?
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Mohit\_Anchlia](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@Mohit\_Anchlia](https://discuss.elastic.co/u/Mohit_Anchlia)\
**Post date:** [November 19, 2013, 1:20am UTC](https://discuss.elastic.co/t/term-query-vs-match-query/14455/3 "2013-11-19T01:20:14Z")

</div>

Thanks that helps! Is analysis mostly based off the lower/upper case? Or  
does it also breaks a text into multiple individual terms?

On Mon, Nov 18, 2013 at 5:14 PM, Nikolas Everett [nik9000@gmail.com](mailto:nik9000@gmail.com) wrote:

> The match query analyzes the input string and constructs more basic  
> queries from that.
> 
> The term query matches exact terms.
> 
> If you have a document containing "CAT" and search for "cat" the match  
> query will find it but the term query won't. That is, if you lowercase in  
> your analysis config which it does by default.
> 
> On Mon, Nov 18, 2013 at 8:11 PM, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com)wrote:
> 
> > Could somebody help me understand the difference between a term query and  
> > a match query? I saw the explanation on the elasticsearch site but couldn't  
> > quite follow. Isn't search always trying to match terms?
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [November 19, 2013, 1:33am UTC](https://discuss.elastic.co/t/term-query-vs-match-query/14455/4 "2013-11-19T01:33:22Z")

</div>

Both. And stemming if your field has that. And stopwords. It uses the configured query analyzer for that field which defaults to the index analyzer for that field which defaults to the "standard" analyzer.

For non strings match will parse strings into that type.

It can do more stuff too but you can read about that on the page.

Sent from my iPhone

> On Nov 18, 2013, at 8:20 PM, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com) wrote:
> 
> Thanks that helps! Is analysis mostly based off the lower/upper case? Or does it also breaks a text into multiple individual terms?
> 
> > On Mon, Nov 18, 2013 at 5:14 PM, Nikolas Everett [nik9000@gmail.com](mailto:nik9000@gmail.com) wrote:  
> > The match query analyzes the input string and constructs more basic queries from that.
> > 
> > The term query matches exact terms.
> > 
> > If you have a document containing "CAT" and search for "cat" the match query will find it but the term query won't. That is, if you lowercase in your analysis config which it does by default.
> > 
> > > ## On Mon, Nov 18, 2013 at 8:11 PM, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com) wrote: Could somebody help me understand the difference between a term query and a match query? I saw the explanation on the elasticsearch site but couldn't quite follow. Isn't search always trying to match terms?
> > > 
> > > You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dhondup](https://avatars.discourse-cdn.com/v4/letter/d/f1d935/32.png) [@dhondup](https://discuss.elastic.co/u/dhondup)\
**Post date:** [August 26, 2016, 1:17pm UTC](https://discuss.elastic.co/t/term-query-vs-match-query/14455/5 "2016-08-26T13:17:14Z")

</div>

So does that mean term query execute faster since it does not involve analysis?

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [August 26, 2016, 1:57pm UTC](https://discuss.elastic.co/t/term-query-vs-match-query/14455/6 "2016-08-26T13:57:03Z")

</div>

Yes, term query is going to be a bit faster but for user provided text you really need to analyze it for the queries to work properly. I mostly use term queries for keyword style fields where analysis doesn't make sense. Like if I user is picking from a drop down or ticking a box or something.

---

<div class="post-metadata">

**Author:** ![dhondup](https://avatars.discourse-cdn.com/v4/letter/d/f1d935/32.png) [@dhondup](https://discuss.elastic.co/u/dhondup)\
**Post date:** [August 26, 2016, 2:30pm UTC](https://discuss.elastic.co/t/term-query-vs-match-query/14455/7 "2016-08-26T14:30:52Z")

</div>

Thanks, Nik. That makes sense. I guess match query could be used for full-text search where user might not input the exact keyword, but a variant of the search term such as "Fox", "fox, and "foxes" in the search field.

---

<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 5, 2017, 10:24pm UTC](https://discuss.elastic.co/t/term-query-vs-match-query/14455/8 "2017-07-05T22:24:50Z")

</div>


