Solr Suggester - Rank by boost factor

734 views Asked by At

I want to implement a Solr Suggester (http://wiki.apache.org/solr/Suggester) that ranks suggestions by document boost factor.

As I understand the documentation, the below configuration should work. But the results are still ranked alphabetically.

Any ideas what I'm missing? I use Solr 4.0.0.

Thanks, Mirko

Solrconfig.xml:

...
<requestHandler name="/suggest" class="solr.SearchHandler">
     <lst name="defaults">
        <str name="spellcheck">true</str>
        <str name="spellcheck.count">7</str>
        <str name="spellcheck.onlyMorePopular">true</str>
    </lst>
    <arr name="last-components">
        <str>suggest</str>
    </arr>
</requestHandler>

<searchComponent class="solr.SpellCheckComponent" name="suggest">
    <lst name="spellchecker">
        <str name="name">default</str>
        <str name="field">suggesttext</str>
        <str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
        <str name="lookupImpl">org.apache.solr.spelling.suggest.fst.WFSTLookupFactory</str>
        <str name="buildOnCommit">true</str>
    </lst>
</searchComponent>
...

Schema.xml:

...
<field name="suggesttext" type="text" indexed="true"  stored="true"  multiValued="true"/>
...
<fieldType name="text" class="solr.TextField" omitNorms="false"/>
...

I added three documents with a document boost:

{

"add": {
  "commitWithin": 5000,          
  "overwrite": true,            
  "boost": 3.0,                 
  "doc": {
    "id": "1",
    "suggesttext": "text bb"
  }
},
"add": {
  "commitWithin": 5000,          
  "overwrite": true,            
  "boost": 2.0,                 
  "doc": {
    "id": "2",
    "suggesttext": "text cc"
  }
},
"add": {
  "commitWithin": 5000,          
  "overwrite": true,            
  "boost": 1.0,                 
  "doc": {
    "id": "3",
    "suggesttext": "text aa"
  }
}

}

A query the suggest handler (with spellcheck.q=te) gives the following response:

{
  "responseHeader":{
    "status":0,
    "QTime":6},
  "command":"build",
  "response":{"numFound":3,"start":0,"docs":[
      {
        "id":"1",
        "suggesttext":["text bb"]},
      {
        "id":"2",
        "suggesttext":["text cc"]},
      {
        "id":"3",
        "suggesttext":["text aa"]}]
  },
  "spellcheck":{
    "suggestions":[
      "te",{
        "numFound":3,
        "startOffset":0,
    "endOffset":2,
    "suggestion":["text aa",
      "text bb",
      "text cc"]}]}}

The search results are ranked by boost as expected. However, the suggestions are not ranked by boost (but alphabetically instead). I also tried the TSTLookup and FSTLookup lookup implementations with the same result.

0

There are 0 answers