Syamala
Syamala

Reputation: 173

solr search with keywords having space not giving proper results

I have list of keywords few of them are below

Cheap hotels Dubai hotel extended hotel .... ..

I have store(storeName:HotelsStore) for this and added the keywords above(which have white space) to my store and doing solr indexing. If we search with "Cheap hotels" my store:HotelsStore is not showing reults.

But If I add "Cheaphotels" without space and indexing. If I search with "Cheaphotels" then my desired store(HotelsStore) is showing in results.

Note: We are using lucene 5.4 and solr 5.4.

Please help me on this.

Thanks, Syamala.

Upvotes: 0

Views: 146

Answers (1)

Oyeme
Oyeme

Reputation: 11225

Try to generate word parts using WordDelimiterFilter filter on storeName field.

You could customise this filter how you want.

Just example:

One way of doing so is to specify generateWordParts="1" catenateWords="1" in the analyzer used for indexing, and generateWordParts="1" in the analyzer used for querying. Given that the current StandardTokenizer immediately removes many intra-word delimiters, it is recommended that this filter be used after a tokenizer that leaves them in place (such as WhitespaceTokenizer).

<tokenizer class="solr.WhitespaceTokenizerFactory"/>
      <filter class="solr.WordDelimiterFilterFactory"
            generateWordParts="1"
            generateNumberParts="1"
            catenateWords="1"
            catenateNumbers="1"
            catenateAll="0"
            preserveOriginal="1"
            />

GENERATE_WORD_PARTS set to 1

Causes parts of words to be generated:

"HotelsStore" => "Hotel" "Store"

https://lucene.apache.org/core/4_4_0/analyzers-common/org/apache/lucene/analysis/miscellaneous/WordDelimiterFilter.html

Upvotes: 1

Related Questions