SOLR- search and bring results based on partial search

86 views Asked by At

I have a product old code and new code.The old product code would be like 000000000000988340 and am using hybris + solr search.

I have setup the attribute "oldproductcode" for solr indexing and when i do search 000000000000988340 in the search box ,am getting the results. But what I want is to search only with 988340 instead of using the leading zeros and I want the results to be shown ,how can i do that in Solr settings.

I do see all these options and i did tried the wildcard ,and it doesn't seem to work ,please advise using the following option how can i make this work

enter image description here

2

There are 2 answers

0
Karthik On BEST ANSWER

I simply enabled the option below with PREFIX and it started working . Thanks all for the help.

enter image description here

1
Benkerroum Mohamed On

This approach may work (using EdgeNGramTokenizerFactory) :

In your schema.xml file associated with your Solr server, add this new fieldType :

<fieldType name="text_edge_ngram" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="index">
    <tokenizer class="solr.EdgeNGramTokenizerFactory" minGramSize="1" maxGramSize="25"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.KeywordTokenizerFactory"/>
  </analyzer>
</fieldType>

then apply this custom analyzer to your "oldproductcode" field :

<field name="oldproductcode" type="text_edge_ngram" indexed="true" stored="true"/>

I hope this helps