I am using SOLR's spellcheck component to get suggestions and expected the Hits part to return a number of hits from the new words but it returns zero hits in all cases:
{
"spellcheck":{
"suggestions":[
"pho",
{
"numFound":8,
"startOffset":0,
"endOffset":3,
"suggestion":[
"photo",
"phone",
"phone's",
"phones",
"photography",
"photoimpression's",
"photographers",
"photos"
]
},
"collation",
[
"collationQuery",
"photo",
"hits",
0,
"misspellingsAndCorrections",
[
"pho",
"photo"
]
],
"collation",
[
"collationQuery",
"phone",
"hits",
0,
"misspellingsAndCorrections",
[
"pho",
"phone"
]
],
"collation",
[
"collationQuery",
"phone's",
"hits",
0,
"misspellingsAndCorrections",
[
"pho",
"phone's"
]
],
"collation",
[
"collationQuery",
"phones",
"hits",
0,
"misspellingsAndCorrections",
[
"pho",
"phones"
]
],
"collation",
[
"collationQuery",
"photography",
"hits",
0,
"misspellingsAndCorrections",
[
"pho",
"photography"
]
],
"collation",
[
"collationQuery",
"photoimpression's",
"hits",
0,
"misspellingsAndCorrections",
[
"pho",
"photoimpression's"
]
],
"collation",
[
"collationQuery",
"photographers",
"hits",
0,
"misspellingsAndCorrections",
[
"pho",
"photographers"
]
],
"collation",
[
"collationQuery",
"photos",
"hits",
0,
"misspellingsAndCorrections",
[
"pho",
"photos"
]
]
]
}
}
My settings are:
<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.tst.TSTLookupFactory</str>
<str name="field">text</str>
<float name="threshold">0.005</float>
<str name="buildOnCommit">true</str>
</lst>
</searchComponent>
For my component and
<requestHandler class="org.apache.solr.handler.component.SearchHandler" name="/suggest">
<lst name="defaults">
<str name="spellcheck">true</str>
<str name="spellcheck.dictionary">suggest</str>
<str name="spellcheck.onlyMorePopular">true</str>
<str name="spellcheck.count">5</str>
<str name="spellcheck.collate">true</str>
<str name="spellcheck.maxCollations">10</str>
<str name="spellcheck.collateExtendedResults">true</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>
Any ideas on how I could get this filled in so I could show the #results to the end-user?
Probably a bit late... I had the same problem until I realized that I have to explicitly tell Solr to run the query so it can return hits count.
Your requestHandler needs a QueryComponent
config, the default one is named "query", just add it to your requestHandler's components section.
<arr name="components">
<str>query</str>
<str>suggest</str>
</arr>
Note: This is not needed if the request handler has a defType
param set (specifying which query parser to use).