# Query filter not working

**URL:** https://discuss.elastic.co/t/query-filter-not-working/99771
**Category:** Elasticsearch
**Created:** [September 7, 2017, 9:32pm UTC](https://discuss.elastic.co/t/query-filter-not-working/99771 "2017-09-07T21:32:42Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![sunmesiav](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@sunmesiav](https://discuss.elastic.co/u/sunmesiav)
#### Post date: [September 7, 2017, 9:32pm UTC](https://discuss.elastic.co/t/query-filter-not-working/99771/1 "2017-09-07T21:32:42Z")

</div>

Hi Team,

Iam trying to build a simple query and filter but its not working.

> {  
> "query": {  
> "bool": {  
> "must": [  
> { "match": { "some\_entry": "Not in" }}  
> ],  
> "filter": [  
> { "term": { "some\_area": "XXX\_YY" }}  
> ]  
> }  
> }  
> }

Iam getting 0 hits while my index as many records. Iam trying to search a text in the field some\_entry and if it matches I wanted to filter by some\_area with exact value as XXX\_YY, If I remove the filter Iam getting those records Iam getting the value, wanted to know what Iam doing wrong

Without filter

> {  
> "took": 1,  
> "timed\_out": false,  
> "\_shards": {  
> "total": 5,  
> "successful": 5,  
> "failed": 0  
> },  
> "hits": {  
> "total": 434,  
> "max\_score": 5.82006,  
> "hits": [  
> {  
> "\_index": "logs2",  
> "\_type": "log2",  
> "\_id": "000001635084962",  
> "\_score": 5.82006,  
> "\_source": {  
> "some\_area": "XXX\_YY",  
> "logtypetext": "Internal",  
> "@timestamp": "2017-09-07T20:37:22.905Z",  
> "some\_entry": " Circuit down - Circuit ID not found in the Database",  
> "@version": "1",  
> "request\_id": "000001635084962"  
> }  
> },  
> {  
> "\_index": "logs2",  
> "\_type": "log2",  
> "\_id": "000001010700627",  
> "\_score": 5.82006,  
> "\_source": {  
> "some\_area": "XXX\_YY",  
> "logtypetext": "Internal",  
> "some\_entry\_short": " =================================================",  
> "@timestamp": "2017-09-07T20:37:36.447Z",  
> "some\_entry": " =====================================================================================\nThe customer is not in the list.\n=====================================================================================\n",  
> "@version": "1",  
> "request\_id": "000001010700627"  
> }  
> },  
> ...  
> }  
> }

---

<div class="post-metadata">

### Author: ![sunmesiav](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@sunmesiav](https://discuss.elastic.co/u/sunmesiav)
#### Post date: [September 7, 2017, 10:54pm UTC](https://discuss.elastic.co/t/query-filter-not-working/99771/2 "2017-09-07T22:54:36Z")

</div>

it looks like the term is case sensitive and with lower case Iam getting the results back. Thanks

---

<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: [September 8, 2017, 1:00am UTC](https://discuss.elastic.co/t/query-filter-not-working/99771/3 "2017-09-08T01:00:01Z")

</div>

Term queries do not analyze the query term, whereas match queries will. Use  
term queries only for exact matches.

---

<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: [October 6, 2017, 1:00am UTC](https://discuss.elastic.co/t/query-filter-not-working/99771/4 "2017-10-06T01:00:48Z")

</div>

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