# TermQuery formation when searching a JSON object against a non analyzed string

**URL:** <https://discuss.elastic.co/t/termquery-formation-when-searching-a-json-object-against-a-non-analyzed-string/205366>\
**Category:** Elasticsearch\
**Created:** [October 26, 2019, 6:36pm UTC](https://discuss.elastic.co/t/termquery-formation-when-searching-a-json-object-against-a-non-analyzed-string/205366 "2019-10-26T18:36:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![neham](https://avatars.discourse-cdn.com/v4/letter/n/cdc98d/32.png) [@neham](https://discuss.elastic.co/u/neham)\
**Post date:** [October 26, 2019, 6:36pm UTC](https://discuss.elastic.co/t/termquery-formation-when-searching-a-json-object-against-a-non-analyzed-string/205366/1 "2019-10-26T18:36:41Z")

</div>

I have a mapping like

```auto
{:assignee {:type "string"
            :include_in_all false
            :index "not_analyzed"
            :null_value "unassigned"}}

```

If I want to search a document with assignee as "neha" my query would be  
`{"query": {"bool": {"must": [{"term": {"assignee":"neha"}}]}}}`  
This works perfectly fine.  
What I want to understand is when I pass an JSON object other than string as assignee to terms query, the query execution shows that it is being converted into 4 termQueries for example:  
`{"query": {"bool": {"must": [{"terms": {"assignee": [{"profile_id":"neha"}]}}]}}}`  
Following TermQueries are being used

1. assignee:profile\_id
2. assignee:neha
3. assignee:{
4. assignee:}  
As a result ES still returns search hits because of the second TermQuery. Here assignee is a not analyzed string. Then why are 4 TermQueries being formed here?  
Is this intentional? If not then what would be the use case here?

---

<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:** [November 23, 2019, 6:42pm UTC](https://discuss.elastic.co/t/termquery-formation-when-searching-a-json-object-against-a-non-analyzed-string/205366/2 "2019-11-23T18:42:17Z")

</div>

Closed on November 23, 2019, 6:42pm UTC

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