Hafiz Muhammad Shafiq
Hafiz Muhammad Shafiq

Reputation: 8678

Apache solr exact match of a query with full indexed data

I am using solr 4.8. I have a very basis question. Suppose I have a field is that contains a string e.g. "I am in class" for a document and for second document its value is "class". Now I want to mach query exactly with the stored string. i.e. if user search for class, it should return second document as these two string are equal. It should not return first document as my query and its value do not exactly match.

I want to achieve same in apache solr. How to implement it.

Upvotes: 0

Views: 1348

Answers (1)

Richard Osseweyer
Richard Osseweyer

Reputation: 1744

You need a Keyword Tokenizer. https://cwiki.apache.org/confluence/display/solr/Tokenizers

This tokenizer treats the entire text field as a single token.

As an example in schema xml:

<field name="title" type="exactstring" indexed="true" stored="true" />

 ....

<fieldType name="exactstring" class="solr.TextField" sortMissingLast="true" omitNorms="true">
    <analyzer type="query">
       <tokenizer class="solr.KeywordTokenizerFactory"/>
    </analyzer>
</fieldType>

Upvotes: 1

Related Questions