Delna
Delna

Reputation: 1

exact match functionality in solr

I am working in an e-Commerce project. We are using solr as the search engine. As part of this I need to do exact match like if I am giving a product Id, first it should do the exact match for that productId. If the product id does not exist in the database, it should do the full-text search.

If we are using the keywordTokenizerFactory, it shows only exact match. Suppose, the the exact match is not present in the database. What result it return? Can anyone help me?

Upvotes: 0

Views: 750

Answers (1)

Abhijit Bashetti
Abhijit Bashetti

Reputation: 8658

The end result will depend on the way you are indexing it. if you are using " Keyword Tokenizer " then this tokenizer treats the entire text field as a single token.

If you use Standard then it will splits the text field into tokens, treating whitespace and punctuation as delimiters. Delimiter characters are discarded.

for the product id field don't apply any tokenizer to that field and make it as a String field. String field matches exact patterns.

For the text I would suggest you can go for the standard tokenizer. for the text search you can use the below field type

<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>

Upvotes: 1

Related Questions