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>