You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Marian Steinbach <ma...@gmail.com> on 2011/07/04 12:30:24 UTC

Spellchecker in zero-hit search result

Hi!

I want my spellchecker component to return search query suggestions,
regardless of the number of items in the search results. (Actually I'd
find it most useful in zero-hit cases...)

Currently I only get suggestions if the search returns one ore more hits.

Example: q=place

<response>
  <result name="response" numFound="20" start="0" maxScore="2.2373123"/>
  <lst name="spellcheck">
    <lst name="suggestions">
      <lst name="place">
        <int name="numFound">4</int>
        <int name="startOffset">0</int>
        <int name="endOffset">5</int>
        <arr name="suggestion">
          <str>place</str>
          <str>places</str>
          <str>placed</str>
        </arr>
      </lst>
      <str name="collation">place</str>
    </lst>
  </lst>
</response>

Example: q=placw

<response>
  <result name="response" numFound="0" start="0" maxScore="0.0"/>
  <lst name="spellcheck">
    <lst name="suggestions"/>
  </lst>
</response>

This is my spellchecker configuration (where I already fiddled around
more than probably useful):

<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.TSTLookup</str>
    <str name="field">autocomplete</str>
    <float name="threshold">0.005</float>
    <str name="accuracy">0.1</str>
    <str name="buildOnCommit">true</str>
    <float name="thresholdTokenFrequency">.0000001</float>
  </lst>
</searchComponent>
<requestHandler
class="org.apache.solr.handler.component.SearchHandler"
name="/suggest">
  <lst name="defaults">
    <str name="wt">json</str>
    <str name="spellcheck">true</str>
    <str name="spellcheck.dictionary">suggest</str>
    <str name="spellcheck.onlyMorePopular">false</str>
    <str name="spellcheck.count">4</str>
    <str name="spellcheck.collate">true</str>
  </lst>
  <arr name="components">
    <str>suggest</str>
  </arr>
</requestHandler>


Did I misunderstand anything?

Thanks!

Re: Spellchecker in zero-hit search result

Posted by Marian Steinbach <ma...@sendung.de>.
On Tue, Jul 5, 2011 at 11:24, Marian Steinbach <ma...@sendung.de> wrote:
> On Mon, Jul 4, 2011 at 17:19, Juan Grande <ju...@gmail.com> wrote:
>> ...
>>
>> You can learn how to correctly configure a spellchecker here:
>> http://wiki.apache.org/solr/SpellCheckComponent. Also, I'd recommend to take
>> a look at the example's solrconfig, because it provides an example
>> spellchecker configuration.


I found the problem. My suggest component had the line

  <str name="classname">org.apache.solr.spelling.suggest.Suggester</str>

which I probably copied without knowing what I did. I removed it to
use the default IndexBasedSpellChecker. No I get my suggestions on
zero-hit searches as well.

Thanks again!

Marian

Re: Spellchecker in zero-hit search result

Posted by Marian Steinbach <ma...@sendung.de>.
On Mon, Jul 4, 2011 at 17:19, Juan Grande <ju...@gmail.com> wrote:
> Hi Marian,
>
> I guess that your problem isn't related to the number of results, but to the
> component's configuration. The configuration that you show is meant to set
> up an autocomplete component that will suggest terms from an incomplete user
> input (something similar to what google does while you're typing in the
> search box), see http://wiki.apache.org/solr/Suggester. That's why your
> suggestions to "place" are "places" and "placed", all sharing the "place"
> prefix. But when you search for "placw", the component doesn't return any
> suggestion, because in your index no term begins with "placw".
>
> You can learn how to correctly configure a spellchecker here:
> http://wiki.apache.org/solr/SpellCheckComponent. Also, I'd recommend to take
> a look at the example's solrconfig, because it provides an example
> spellchecker configuration.

Juan, thanks for the information!

I have read through that page for quite a while before doing my tests,
but it seems as if I had a different mental model. Then all reading
might not be worth it. I thought that the SpellCheckComponent would be
able to fetch index terms which are similar to the query term. The use
case for that, mainly (but not only) in case of a zero-hit search
would be to display the famous "Did you mean ..." hint.

So I'm going back to the docs and to the example. :)

Later,

Marian

Re: Spellchecker in zero-hit search result

Posted by Juan Grande <ju...@gmail.com>.
Hi Marian,

I guess that your problem isn't related to the number of results, but to the
component's configuration. The configuration that you show is meant to set
up an autocomplete component that will suggest terms from an incomplete user
input (something similar to what google does while you're typing in the
search box), see http://wiki.apache.org/solr/Suggester. That's why your
suggestions to "place" are "places" and "placed", all sharing the "place"
prefix. But when you search for "placw", the component doesn't return any
suggestion, because in your index no term begins with "placw".

You can learn how to correctly configure a spellchecker here:
http://wiki.apache.org/solr/SpellCheckComponent. Also, I'd recommend to take
a look at the example's solrconfig, because it provides an example
spellchecker configuration.

Regards,

*Juan*

On Mon, Jul 4, 2011 at 7:30 AM, Marian Steinbach <marian.steinbach@gmail.com
> wrote:

> Hi!
>
> I want my spellchecker component to return search query suggestions,
> regardless of the number of items in the search results. (Actually I'd
> find it most useful in zero-hit cases...)
>
> Currently I only get suggestions if the search returns one ore more hits.
>
> Example: q=place
>
> <response>
>  <result name="response" numFound="20" start="0" maxScore="2.2373123"/>
>  <lst name="spellcheck">
>    <lst name="suggestions">
>      <lst name="place">
>        <int name="numFound">4</int>
>        <int name="startOffset">0</int>
>        <int name="endOffset">5</int>
>        <arr name="suggestion">
>          <str>place</str>
>          <str>places</str>
>          <str>placed</str>
>        </arr>
>      </lst>
>      <str name="collation">place</str>
>    </lst>
>  </lst>
> </response>
>
> Example: q=placw
>
> <response>
>  <result name="response" numFound="0" start="0" maxScore="0.0"/>
>  <lst name="spellcheck">
>    <lst name="suggestions"/>
>  </lst>
> </response>
>
> This is my spellchecker configuration (where I already fiddled around
> more than probably useful):
>
> <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.TSTLookup</str>
>    <str name="field">autocomplete</str>
>    <float name="threshold">0.005</float>
>    <str name="accuracy">0.1</str>
>    <str name="buildOnCommit">true</str>
>    <float name="thresholdTokenFrequency">.0000001</float>
>  </lst>
> </searchComponent>
> <requestHandler
> class="org.apache.solr.handler.component.SearchHandler"
> name="/suggest">
>  <lst name="defaults">
>    <str name="wt">json</str>
>    <str name="spellcheck">true</str>
>    <str name="spellcheck.dictionary">suggest</str>
>    <str name="spellcheck.onlyMorePopular">false</str>
>    <str name="spellcheck.count">4</str>
>    <str name="spellcheck.collate">true</str>
>  </lst>
>  <arr name="components">
>    <str>suggest</str>
>  </arr>
> </requestHandler>
>
>
> Did I misunderstand anything?
>
> Thanks!
>