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 abhayd <aj...@hotmail.com> on 2010/10/25 14:16:05 UTC

solr 1.4 suggester component

hi
I was looking into using solr suggester component as described in
http://wiki.apache.org/solr/Suggester

I have a file which has words, phrases in it.

I was wondering how to make following possible.

file has
-------------
rebate form
form

when i look for "form" or even "for" i would like to have rebate form to be
included too.
I tried using
      <str
name="lookupImpl">org.apache.solr.spelling.suggest.jaspell.JaspellLookup</str>
but no luck, wiki suggests some one liner change to get fuzzy suggestions.
But not sure whats that one liner change would be

Also wiki suggests "* If you want to use a dictionary file that contains
phrases (actually, strings that can be split into multiple tokens by the
default QueryConverter) then define a different QueryConverter "
but i dont see the desired result
here is my solrconfig.xml

<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="lookupImpl">org.apache.solr.spelling.suggest.jaspell.JaspellLookup</str>
      <str name="sourceLocation">american-english.txt</str>
      <str name="field">name</str>  <!-- the indexed field to derive
suggestions from -->
      <float name="threshold">0.005</float>
      <str name="buildOnCommit">false</str>
      <queryConverter name="queryConverter"
class="org.apache.solr.spelling.MySpellingQueryConverter"/>
    </lst>
  </searchComponent>
  <requestHandler class="org.apache.solr.handler.component.SearchHandler"
name="/suggest">
    <lst name="defaults">
      <str name="spellcheck">false</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>
    </lst>
    <arr name="components">
      <str>suggest</str>
    </arr>
  </requestHandler> 
-- 
View this message in context: http://lucene.472066.n3.nabble.com/solr-1-4-suggester-component-tp1766915p1766915.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: solr 1.4 suggester component

Posted by abhayd <aj...@hotmail.com>.
thanks ..

i used
http://www.lucidimagination.com/blog/2009/09/08/auto-suggest-from-popular-queries-using-edgengrams/

with fuzzy operator..
-- 
View this message in context: http://lucene.472066.n3.nabble.com/solr-1-4-suggester-component-tp1766915p2012946.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: solr 1.4 suggester component

Posted by Erick Erickson <er...@gmail.com>.
Sorry it took so long to respond, I got wrapped up in work. I don't think
you're
going to be able to pull this off (but of course I've been wrong before).
File based
suggestions look like they do an awful lot of stuff for you, at some expense
of
customization (no surprise here).

That said, though, there's no need to have a second core if you wanted to
do something yourself. Remember that Solr documents do not need to have
the same fields. So, you could easily create a "document" that simply had
one huge field NOT in common with any other document. Go ahead and
index into this field from the dictionary file any way you want. Your
autosuggest
can then operate off this field, customized however you want. Recent Solr
builds have an example of how to do this through Ajax calls by going against
a specific field. You embed a bit of Javascript in your page that makes
calls
to get terms from the relevant field. See layout.vm and browse.vm in the
example
code for a sense of how this can occur....

HTH
Erick

On Mon, Oct 25, 2010 at 10:31 AM, abhayd <aj...@hotmail.com> wrote:

>
> hi erick,
> Thanks for the link.
>
> Problem is we dont want to have another solr core for implementing this, So
> was trying suggester component as it allows file based auto suggest.
>
> It works fine only issue is how to get prefix ignored . Any idea?
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/solr-1-4-suggester-component-tp1766915p1767639.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: solr 1.4 suggester component

Posted by abhayd <aj...@hotmail.com>.
hi erick,
Thanks for the link.

Problem is we dont want to have another solr core for implementing this, So
was trying suggester component as it allows file based auto suggest.

It works fine only issue is how to get prefix ignored . Any idea?
-- 
View this message in context: http://lucene.472066.n3.nabble.com/solr-1-4-suggester-component-tp1766915p1767639.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: solr 1.3 suggester component

Posted by abhayd <aj...@hotmail.com>.
hi erick,
I was able to implement this using link you posted.
I am using SOLR 1.3

I wanted to add spellcheck component to it so did this
  <requestHandler name="standard" class="solr.SearchHandler" default="true">
    <!-- default values for query parameters -->
     <lst name="defaults">
       <str name="echoParams">explicit</str>
       <arr name="last-components">
      	<str>spellcheck</str>
       </arr>
     </lst>
  </requestHandler>

but for some reason it does not return suggestion for misspelled words. For
instance iphole does not get a suggestion of iphone.
here is my query
http://localhost:10101/solr/core1/select?q=user_query:iphole&spellcheck=true&spellcheck.collate=true

At the same time when I added another request handler 
 <requestHandler name="/spell" class="solr.SearchHandler" lazy="true">
    <lst name="defaults">
      <!-- omp = Only More Popular -->
      <str name="spellcheck.onlyMorePopular">false</str>
      <!-- exr = Extended Results -->
      <str name="spellcheck.extendedResults">false</str>
      <!--  The number of suggestions to return -->
      <str name="spellcheck.count">1</str>
    </lst>
    <arr name="last-components">
      <str>spellcheck</str>
    </arr>
  </requestHandler>
it works fine and returns suggestion
here is my query
http://localhost:10101/solr/core1/spell?q=iphole&spellcheck=true&spellcheck.collate=true
-- 
View this message in context: http://lucene.472066.n3.nabble.com/solr-1-4-suggester-component-tp1766915p1784255.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: solr 1.4 suggester component

Posted by Erick Erickson <er...@gmail.com>.
Try here:
http://www.lucidimagination.com/blog/2009/09/08/auto-suggest-from-popular-queries-using-edgengrams/

<http://www.lucidimagination.com/blog/2009/09/08/auto-suggest-from-popular-queries-using-edgengrams/>For
the infix-type match you're using, you might not want the
"edge" version of ngram...

Best
Erick

On Mon, Oct 25, 2010 at 8:16 AM, abhayd <aj...@hotmail.com> wrote:

>
> hi
> I was looking into using solr suggester component as described in
> http://wiki.apache.org/solr/Suggester
>
> I have a file which has words, phrases in it.
>
> I was wondering how to make following possible.
>
> file has
> -------------
> rebate form
> form
>
> when i look for "form" or even "for" i would like to have rebate form to be
> included too.
> I tried using
>      <str
>
> name="lookupImpl">org.apache.solr.spelling.suggest.jaspell.JaspellLookup</str>
> but no luck, wiki suggests some one liner change to get fuzzy suggestions.
> But not sure whats that one liner change would be
>
> Also wiki suggests "* If you want to use a dictionary file that contains
> phrases (actually, strings that can be split into multiple tokens by the
> default QueryConverter) then define a different QueryConverter "
> but i dont see the desired result
> here is my solrconfig.xml
>
> <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="lookupImpl">org.apache.solr.spelling.suggest.jaspell.JaspellLookup</str>
>      <str name="sourceLocation">american-english.txt</str>
>      <str name="field">name</str>  <!-- the indexed field to derive
> suggestions from -->
>      <float name="threshold">0.005</float>
>      <str name="buildOnCommit">false</str>
>      <queryConverter name="queryConverter"
> class="org.apache.solr.spelling.MySpellingQueryConverter"/>
>    </lst>
>  </searchComponent>
>  <requestHandler class="org.apache.solr.handler.component.SearchHandler"
> name="/suggest">
>    <lst name="defaults">
>      <str name="spellcheck">false</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>
>    </lst>
>    <arr name="components">
>      <str>suggest</str>
>    </arr>
>  </requestHandler>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/solr-1-4-suggester-component-tp1766915p1766915.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>