# Filtered text query

**URL:** <https://discuss.elastic.co/t/filtered-text-query/8039>\
**Category:** Elasticsearch\
**Created:** [June 11, 2012, 8:53am UTC](https://discuss.elastic.co/t/filtered-text-query/8039 "2012-06-11T08:53:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vipul](https://avatars.discourse-cdn.com/v4/letter/v/cdc98d/32.png) [@Vipul](https://discuss.elastic.co/u/Vipul)\
**Post date:** [June 11, 2012, 8:53am UTC](https://discuss.elastic.co/t/filtered-text-query/8039/1 "2012-06-11T08:53:21Z")

</div>

I am doing the following query:  
{"size":20000,"query":{"filtered":{"query":{match\_all:{}},"filter":{"or":[{"term":{CATEGORY:"diamonds"}},{"term":{CATEGORY:"fashion"}}]}}}}

This works fine. What I need now is that the 'CATEGORY' has names such as  
Men Clothing and Men Accessories. So I want to do a text query. But when I  
replaced term with text, it didnt work for me. What to do?

---

<div class="post-metadata">

**Author:** ![Anne\_Veling](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anne_veling/32/1260_2.png) [@Anne\_Veling](https://discuss.elastic.co/u/Anne_Veling)\
**Post date:** [June 12, 2012, 8:08am UTC](https://discuss.elastic.co/t/filtered-text-query/8039/2 "2012-06-12T08:08:37Z")

</div>

How is the Category field analyzed/tokenized? If it has a standard  
analyzer, it could be that it actually lowercases and tokenizes the "men  
clothing" token into two terms "men" and "clothing".  
It looks like what you would need is a non-tokenizer (keyword) analyzer on  
that field, so you can find it back exactly as you enter it (including  
capitalization)?

Anne

On Mon, Jun 11, 2012 at 10:53 AM, Vipul Jain [awesomevipul@gmail.com](mailto:awesomevipul@gmail.com) wrote:

> I am doing the following query:
> 
> {"size":20000,"query":{"filtered":{"query":{match\_all:{}},"filter":{"or":[{"term":{CATEGORY:"diamonds"}},{"term":{CATEGORY:"fashion"}}]}}}}
> 
> This works fine. What I need now is that the 'CATEGORY' has names such as  
> Men Clothing and Men Accessories. So I want to do a text query. But when I  
> replaced term with text, it didnt work for me. What to do?

--  
Anne Veling  
[BeyondTrees.com](http://BeyondTrees.com)  
+31 6 50 969 170  
@anneveling

---

<div class="post-metadata">

**Author:** ![Vipul](https://avatars.discourse-cdn.com/v4/letter/v/cdc98d/32.png) [@Vipul](https://discuss.elastic.co/u/Vipul)\
**Post date:** [June 12, 2012, 8:10am UTC](https://discuss.elastic.co/t/filtered-text-query/8039/3 "2012-06-12T08:10:30Z")

</div>

Ya thanks..I figured out.. I just had to index as not\_analyzed and it  
worked..

On Monday, 11 June 2012 14:23:21 UTC+5:30, Vipul Jain wrote:

> I am doing the following query:
> 
> {"size":20000,"query":{"filtered":{"query":{match\_all:{}},"filter":{"or":[{"term":{CATEGORY:"diamonds"}},{"term":{CATEGORY:"fashion"}}]}}}}
> 
> This works fine. What I need now is that the 'CATEGORY' has names such as  
> Men Clothing and Men Accessories. So I want to do a text query. But when I  
> replaced term with text, it didnt work for me. What to do?

---

<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, 3:24am UTC](https://discuss.elastic.co/t/filtered-text-query/8039/4 "2017-07-06T03:24:51Z")

</div>

Closed on July 6, 2017, 3:24am UTC


