# Looking for source code that shows term based query analyzer behavior

**URL:** <https://discuss.elastic.co/t/looking-for-source-code-that-shows-term-based-query-analyzer-behavior/65001>\
**Category:** Elasticsearch\
**Created:** [November 4, 2016, 10:33am UTC](https://discuss.elastic.co/t/looking-for-source-code-that-shows-term-based-query-analyzer-behavior/65001 "2016-11-04T10:33:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![renanvicente](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/renanvicente/32/12956_2.png) [@renanvicente](https://discuss.elastic.co/u/renanvicente)\
**Post date:** [November 4, 2016, 10:33am UTC](https://discuss.elastic.co/t/looking-for-source-code-that-shows-term-based-query-analyzer-behavior/65001/1 "2016-11-04T10:33:48Z")

</div>

Hey guys,

Does anyone know where is the part of the ElasticSearch code that has the behavior of term query with analyzer?

"Queries like the term or fuzzy queries are low-level queries that have no  
analysis phase. They operate on a single term. A term query for the term  
Foo looks for that exact term in the inverted index and calculates the  
TF/IDF relevance \_score for each document that contains the [term.It](http://term.It) is important to remember that the term query looks in the inverted index  
for the exact term only; it won’t match any variants like foo or  
FOO. It doesn’t matter how the term came to be in the index, just that it  
is. If you were to index ["Foo","Bar"] into an exact value not\_analyzed  
field, or Foo Bar into an analyzed field with the whitespace analyzer,  
both would result in having the two terms Foo and Bar in the inverted  
index."

Just wanted to understand a bit better by reading the code.

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [November 4, 2016, 11:25am UTC](https://discuss.elastic.co/t/looking-for-source-code-that-shows-term-based-query-analyzer-behavior/65001/2 "2016-11-04T11:25:35Z")

</div>

> [@renanvicente](#):
>
> where is the part of the Elasticsearch code that has the behavior of term query with analyzer?

The documentation you pasted describes the fact that `term` query does _not_ use an analyzer so I can't point you at any code for `term` query with analyzer.  
If you want your search input to be analyzed consider using the `match` query which offers field-sensitive analysis.

---

<div class="post-metadata">

**Author:** ![renanvicente](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/renanvicente/32/12956_2.png) [@renanvicente](https://discuss.elastic.co/u/renanvicente)\
**Post date:** [November 4, 2016, 11:30am UTC](https://discuss.elastic.co/t/looking-for-source-code-that-shows-term-based-query-analyzer-behavior/65001/3 "2016-11-04T11:30:56Z")

</div>

Thank you for your time to reply. from what I understood. If you are using the default analyzer (standard) and you inserted a data with name uppercase for example like TEST and I do a query term looking for TEST it won't find anything because the query looks for the analyzed result which is "test". I wanted to find the part of the code that shows that it queries the already analyzed value.

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [November 4, 2016, 11:43am UTC](https://discuss.elastic.co/t/looking-for-source-code-that-shows-term-based-query-analyzer-behavior/65001/4 "2016-11-04T11:43:36Z")

</div>

Generally, parsers turn user-criteria into Query objects which are part of Apache Lucene (the open source search engine we help maintain). That rabbit-hole goes quite deep so maybe a better starting point is to look at the `explain` api which shows the low-level terms that are being generated by the Lucene Query objects.

---

<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:06pm UTC](https://discuss.elastic.co/t/looking-for-source-code-that-shows-term-based-query-analyzer-behavior/65001/5 "2017-07-05T22:06:33Z")

</div>


