# Match vs term query

**URL:** <https://discuss.elastic.co/t/match-vs-term-query/14512>\
**Category:** Elasticsearch\
**Created:** [November 21, 2013, 9:01am UTC](https://discuss.elastic.co/t/match-vs-term-query/14512 "2013-11-21T09:01:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![paul1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul1/32/46819_2.png) [@paul1](https://discuss.elastic.co/u/paul1)\
**Post date:** [November 21, 2013, 9:01am UTC](https://discuss.elastic.co/t/match-vs-term-query/14512/1 "2013-11-21T09:01:46Z")

</div>

mapping is

- plan:  
{
  - type: "string"  
}

data:

- plan: Not Available
- plan: Available
- plan: Not Available
- plan: Not Available

The below query returns results.  
"query": {  
"match": {  
"plan": "Not Available"  
}  
}

If i change match to term i get zero results, though the terms are present  
in data.  
"query": {  
"term": {  
"plan": "Not Available"  
}  
}

--  
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:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 21, 2013, 9:28am UTC](https://discuss.elastic.co/t/match-vs-term-query/14512/2 "2013-11-21T09:28:47Z")

</div>

Because your analyzer for that field is the standard one.  
It index you field « Not Available » into « available ».

You need to use a keyword analyzer or not analyze at all the field if you want to use the TermQuery here.

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 21 novembre 2013 at 10:01:50, paul ([avinashpaul85@gmail.com](mailto:avinashpaul85@gmail.com)) a écrit:

mapping is  
plan: {  
type: "string"  
}

data:  
plan: Not Available  
plan: Available  
plan: Not Available  
plan: Not Available

The below query returns results.  
"query": {  
"match": {  
"plan": "Not Available"  
}  
}

If i change match to term i get zero results, though the terms are present in data.  
"query": {  
"term": {  
"plan": "Not Available"  
}  
}

--  
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:** ![paul1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul1/32/46819_2.png) [@paul1](https://discuss.elastic.co/u/paul1)\
**Post date:** [November 21, 2013, 11:33am UTC](https://discuss.elastic.co/t/match-vs-term-query/14512/3 "2013-11-21T11:33:10Z")

</div>

thank you for the clarification , after the changes it works ,one  
clarification the standard analyzer converts it to lower case and removes  
the "Not".

Regards  
Paul

On Thursday, 21 November 2013 14:58:47 UTC+5:30, David Pilato wrote:

> Because your analyzer for that field is the standard one.  
> It index you field « Not Available » into « available ».
> 
> You need to use a keyword analyzer or not analyze at all the field if you  
> want to use the TermQuery here.
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)
> 
> Le 21 novembre 2013 at 10:01:50, paul ([avinas...@gmail.com](mailto:avinas...@gmail.com) \<javascript:\>)  
> a écrit:
> 
> mapping is
> 
> - plan:  
> {
> - type: "string"  
> }
> 
> data:
> 
> - plan: Not Available
> - plan: Available
> - plan: Not Available
> - plan: Not Available
> 
> The below query returns results.  
> "query": {  
> "match": {  
> "plan": "Not Available"  
> }  
> }
> 
> If i change match to term i get zero results, though the terms are present  
> in data.  
> "query": {  
> "term": {  
> "plan": "Not Available"  
> }  
> }
> 
> --  
> 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> 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:** ![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, 2:05am UTC](https://discuss.elastic.co/t/match-vs-term-query/14512/4 "2017-07-06T02:05:41Z")

</div>


