Filtered text query


(Vipul) #1

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) #2

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 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
+31 6 50 969 170
@anneveling


(Vipul) #3

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?


(system) #4