# Match Vs. Term

**URL:** <https://discuss.elastic.co/t/match-vs-term/73020>\
**Category:** Elasticsearch\
**Created:** [January 27, 2017, 2:17pm UTC](https://discuss.elastic.co/t/match-vs-term/73020 "2017-01-27T14:17:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emrah](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emrah/32/17657_2.png) [@Emrah](https://discuss.elastic.co/u/Emrah)\
**Post date:** [January 27, 2017, 2:17pm UTC](https://discuss.elastic.co/t/match-vs-term/73020/1 "2017-01-27T14:17:18Z")

</div>

Hey there ,

I know that this type of question asked before in some other cases but i really need this to be sure if in my case, **Match query** or **Term quer** y is **faster**.

I'm gonna ask the question with an example :

The text that i'm gonna **search**  **"john-doe-amsterdam-other-field-other-field-...."**

In my **index** ;  
**person: "john-doe"** ,  
city:"amsterdam",  
other\_field : "other-field",  
other\_field : "other-field",

I know that amsterdam is a city and can handle extra fields but "john-doe" in my application. So in this case i have two options.  
1- Split the text remove amsterdam and other extra fields before search and do a **Term query** on person.  
2- Analyze the text( **"john-doe-amsterdam-other-field-other-field** ) while **indexing** with **pattern tokinizer ("-")** and do a **Match Query.**  
(The output of analyze will be indexed i think and match query will check a list of string.)

So in this case, i guess text = field will be faster than list = list

Anyway which method would you choose ? Doing string process in web server and then ask Elasticsearch or leave it to ElasticSearch completely ? Does match query run as well as term query in any circumstances?

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [January 27, 2017, 7:14pm UTC](https://discuss.elastic.co/t/match-vs-term/73020/2 "2017-01-27T19:14:24Z")

</div>

If you analyze the text during indexing with a pattern tokenizer, then you  
should be able to do a match query as well since each term will be indexed  
as a separate token, assuming you do not further alter terms with stemming,  
synonyms, etc and the casing matches.

The speed of the actual term and match query should not make a difference  
since they both use the same inverted index. The match query will go  
through the extra step of analyzing the query term, but I believe the the  
performance of this extra step to be negligible.

Precision is a different matter. The term query will be accurate if you  
want exact matching for "john-doe".

---

<div class="post-metadata">

**Author:** ![Emrah](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emrah/32/17657_2.png) [@Emrah](https://discuss.elastic.co/u/Emrah)\
**Post date:** [January 30, 2017, 6:34am UTC](https://discuss.elastic.co/t/match-vs-term/73020/3 "2017-01-30T06:34:22Z")

</div>

Nope there will be no stemming, synonyms or something like that. Actually i want to find combinations of "john-doe" like "john-doe-field1-field2" , "john-doe-amsterdam-field2-field1" .... goes on. I can make an exact search on "john-doe" with splitting and replacing the text but the question is should i do that ?

---

<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:** [February 27, 2017, 6:34am UTC](https://discuss.elastic.co/t/match-vs-term/73020/4 "2017-02-27T06:34:26Z")

</div>

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