1

I have keyword field in Solr schema.

<fieldType name="text_keyword" class="solr.TextField" positionIncrementGap="100">
<analyzer>
<tokenizer class="solr.SimpleKeywordTokenizerFactory"/>
</analyzer>
</fieldType>

When I try to search this field with default solr query or dismax query category:(Mouse Pad) it creates query (category:Mouse) AND (category:Pad)

I want to know is there a way not to split terms by whitespaces if it is keyword field or so.

Added: I need SimpleKeywordTokenizerFactory analyze (which is lowercase without white-space splitting) on query, so raw and term query parser doesn't work for me

yura
  • 14,489
  • 21
  • 77
  • 126

2 Answers2

1

You want to enter this query:

category:"Mouse Pad"

The query syntax already provides a way to do this. Quotes are for phrases. Parentheses mean something different. You can write your own query parser if you want, but I don't recommend it.

Walter Underwood
  • 1,201
  • 9
  • 11
0

You could use TermQParserPlugin:

{!term f=category}Mouse Pad

Beware that no analysis is performed, so this will only work if the internal representation of your field is "Mouse Pad" (with title case).

Edit (2012-04-17):

If you still want analysis to be performed, all you need to do is to escape the space by prepending a backslash:

{!lucene}category:Mouse\ Pad

jpountz
  • 9,904
  • 1
  • 31
  • 39
  • Yes I can also do this with {!raw} . But actually I want to do some field analyze(like lowercase). The only think I don't want is white-space splitting and keyword analyzer don't do this, but query parser does... – yura Apr 16 '12 at 21:01