You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Zac Smith <za...@trinkit.com> on 2012/02/09 21:51:56 UTC

Keyword Tokenizer Phrase Issue

Hi,

I have a simple field type that uses the KeywordTokenizerFactory. I would like to use this so that values in this field are only matched with the full text of the field.
e.g. If I indexed the text 'chicken stock', searches on this field would only match when searching for 'chicken stock'. If searching for just 'chicken' or just 'stock' there should not match.

This mostly works, except if there is more than one word in the text I only get a match when searching with quotes. e.g.
"chicken stock" (matches)
chicken stock (doesn't match)

Is there any way I can set this up so that I don't have to provide quotes? I am using dismax and if I put quotes in it will mess up the search for the rest of my fields. I had an idea that I could issue a separate search using the regular query parser, but couldn't work out how to do this:
I thought I could do something like this: qt=dismax&q=fish OR _query_:ingredient:"chicken stock"

I am using solr 3.5.0. My field type is:
<fieldType name="keyword_test" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true">
                <analyzer type="index">
                                <tokenizer class="solr.KeywordTokenizerFactory" />
                </analyzer>
                <analyzer type="query">
                                <tokenizer class="solr.KeywordTokenizerFactory" />
                </analyzer>
</fieldType>

Thanks
Zac