0

I have a requirement to boost a term/s in solr 4.7.x auto suggest response based on the boost value for each term and this boosting is for some set of terms defined in a file (and business can manage this file).

I have a design to extend the existing response writer or write a custom plugin and
For ex: mydic.suggest file will look like
eagles 40.00 hits 20.00 hosted 30.00l

when i start typing

-->Query1 : "(http://example.com/solr/collection1/suggest?q=eag)"

Original solr response will be (based on my index) suggestion: {
eager,
eagles
}

so the suggest response should be changed to
suggestion:{
eagles,
eager
}

-->Query2 : "(http://example.com/solr/collection1/suggest?q=ho)" original Solr response will be (based on my index)

suggestion: { holiday,
holly,
home,
hometown,
hop,
hope,
hosted
}

so the suggest response should be changed to -- observe the term "hosted" to come up

suggestion:{ hosted,
holiday,
holly,
home,
hometown,
hop,
hope
}

Is this doable with custom solr plugin?

My suggest handler with Dic looks like ::

<searchComponent class="solr.SpellCheckComponent" name="suggest">
    <lst name="spellchecker">
      <str name="name">suggest</str>
      <str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
      <str name="lookupImpl">org.apache.solr.spelling.suggest.fst.WFSTLookupFactory</str>
      <!-- Alternatives to lookupImpl: 
           org.apache.solr.spelling.suggest.fst.FSTLookupFactory   [finite state automaton]
           org.apache.solr.spelling.suggest.fst.WFSTLookupFactory [weighted finite state automaton]
           org.apache.solr.spelling.suggest.jaspell.JaspellLookupFactory [default, jaspell-based]
           org.apache.solr.spelling.suggest.tst.TSTLookupFactory   [ternary trees]

      <str name="comparatorClass">freq</str>-->
      <str name="sourceLocation ">./../suggest/autoSuggestDic.txt</str>
      <str name="field">textSuggest</str>  <!-- the indexed field to derive suggestions from -->
      <str name="buildOnCommit">true</str>
      <bool name="exactMatchFirst">true</bool>
    </lst>
     <!-- specify a fieldtype using keywordtokenizer + lowercase + cleanup -->
    <str name="queryAnalyzerFieldType">text_general</str>
  </searchComponent>
  <requestHandler class="org.apache.solr.handler.component.SearchHandler" name="/suggest">
    <lst name="defaults">
      <str name="name">suggest</str>
      <str name="spellcheck">true</str>
      <str name="spellcheck.dictionary">suggest</str>
      <str name="spellcheck.onlyMorePopular">false</str>
      <str name="spellcheck.count">15</str>   
      <str name="spellcheck.collate">true</str>
    </lst>
    <arr name="components">
      <str>suggest</str>
    </arr>
  </requestHandler>
Rajesh
  • 83
  • 11
  • Have you looked at the [Dictionary support in Suggester](http://wiki.apache.org/solr/Suggester#Dictionary) ? – Srikanth Venugopalan May 23 '14 at 03:17
  • Yes i have gone through that setting for my suugest handler with my dic as # simple auto-suggest phrase dictionary for testing # note this uses tabs as separator! howard 100.0 hits 3.0 testing 3.0 eagles 5.0 stern 5.0 show 5.0 FYI my suggest handler with dic looks like-- Please see my updated question, Thanks Srikanth for your suggestion. – Rajesh May 23 '14 at 15:01

1 Answers1

0

I have this now working with solr 4.7 both dictionary support and index dictionary.

My custom suggest handler builds HighFrequencyDictionary( which is build using my Index) instance and FileDictionary (which is my dictionary file mentioned as

./../autoSuggestDic.dic in solrConfig.xml) instance

in build(...) method and custom getSuggestions(SpellingOptions options){..} method uses both of these dictionaries for suggestion.

This is similar to boost of your suggestion terms as boost of your search results.

Rajesh
  • 83
  • 11