2
votes

Hello everyone i am using solr 4.10 and i am not getting the result as per my expectation. i want to get auto complete suggestion using multiple fields that is discountCatName,discountSubName and vendorName. i have a created multi-valued field "suggestions" using copyfield and using that filed for searching in suggester configuration.

Note: discountSubName & discountCatName are again multi-valued field, vendorName is string. This is a suggestion field data from one of my document:

"suggestions": [ 
  "Budget Car Rental", 
  "Car Rentals", 
  "Business Deals", 
  "Auto", 
  "Travel", 
  "Car Rentals" ]

If i type for a "car" i am getting "Budget Car Rental" in my suggestion but not "Car Rentals", below are my configurations. let me know if i need to change the tokenizer and filters.Any help in this would be appreciate.

Below is my code block as per explained the scenario above.

Suggestion field,fieldType,searchComponent and request handler respectively which i am using for auto complete suggestions

<!--suggestion field -->
<field name="suggestions" type="suggestType" indexed="true" stored="true" multiValued="true"/>
<copyField source="discountCatName" dest="suggestions"/>
<copyField source="discountSubName" dest="suggestions"/>
<copyField source="vendorName" dest="suggestions"/>
<!--suggest fieldType -->

<fieldType name="suggestType" class="solr.TextField" positionIncrementGap="100">
  <analyzer>
    <charFilter class="solr.PatternReplaceCharFilterFactory" pattern="[^a-zA-Z0-9]" replacement=" " />
    <tokenizer class="solr.WhitespaceTokenizerFactory"/>
    <filter class="solr.StandardFilterFactory"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
    <filter class="solr.RemoveDuplicatesTokenFilterFactory" />
  </analyzer>
</fieldType>

<!--suggest searchComponent configuration -->
<searchComponent name="suggest" class="solr.SuggestComponent">
  <lst name="suggester">
    <str name="name">analyzing</str>
    <str name="lookupImpl">BlendedInfixLookupFactory</str>
    <str name="suggestAnalyzerFieldType">suggestType</str>
    <str name="blenderType">linear</str>
    <str name="minPrefixChars">1</str>
    <str name="doHighlight">false</str>
    <str name="weightField">score</str>
    <str name="dictionaryImpl">DocumentDictionaryFactory</str>
    <str name="field">suggestions</str>
    <str name="buildOnStartup">true</str>
    <str name="buildOnCommit">true</str>
  </lst>
</searchComponent>

<!--suggest request handler -->
<requestHandler name="/suggest" class="solr.SearchHandler" startup="lazy" >
  <lst name="defaults">
    <str name="suggest">true</str>
    <str name="suggest.count">10</str>
    <str name="suggest.dictionary">analyzing</str>
  </lst>
  <arr name="components">
    <str>suggest</str>
  </arr>
</requestHandler>
1

1 Answers

1
votes

I just discovered by debugging Solr 4.10 source code there is a bug in DocumentDictionaryFactory lookup, it's always look in the first string incase of multi-valued field and then stop suggestion from that document hence i am not getting expected output from my above configuration.

I have a created a separate index for all the fields i want to apply search like catName0...catName10, subName0...subName10 and then created multiple suggestion dictionaries for each fields and lastly i parsed the response form all the suggestion dictionary merged them and sorted based on weight and highlight position.

Lengthy approach but no other way as this solr 4.10 was required.