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 Ryan Yacyshyn <ry...@gmail.com> on 2015/11/27 04:41:52 UTC

Spellcheck on first character

Hi all,

Is it possible to provide spelling suggestions if it's just the first
character that's wrong (or has an additional character added)?

We have users querying for "eappointment" when they should just be
searching for "appointment". I'd like to show "appointment" as a spelling
suggestion for "eappointment".

Is this possible?

I'm using 4.10.1 and below are my configs:

*<!-- the **spellchecking** defaults in my **requestHandler** -->*
<str name="spellcheck">on</str>
<str name="spellcheck.extendedResults">false</str>
<str name="spellcheck.count">1</str>
<str name="spellcheck.alternativeTermCount">1</str>
<str name="spellcheck.maxResultsForSuggest">1</str>
<str name="spellcheck.collate">true</str>
<str name="spellcheck.collateExtendedResults">false</str>
<str name="spellcheck.maxCollationTries">5</str>
<str name="spellcheck.maxCollations">1</str>

*<!-- **spellchecking** component -->*
<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
  <!-- a spellchecker built from a field of the main index -->
  <lst name="spellchecker">
    <str name="name">default</str>
    <str name="field">spell</str>
    <str name="classname">solr.DirectSolrSpellChecker</str>
    <!-- the spellcheck distance measure used, the default is the internal
levenshtein -->
    <str name="distanceMeasure">internal</str>
    <!-- minimum accuracy needed to be considered a valid spellcheck
suggestion -->
    <float name="accuracy">0.5</float>
    <!-- the maximum #edits we consider when enumerating terms: can be 1 or
2 -->
    <int name="maxEdits">2</int>
    <!-- the minimum shared prefix when enumerating terms -->
    <int name="minPrefix">1</int>
    <!-- maximum number of inspections per result. -->
    <int name="maxInspections">5</int>
    <!-- minimum length of a query term to be considered for correction -->
    <int name="minQueryLength">4</int>
    <!-- maximum threshold of documents a query term can appear to be
considered for correction -->
    <float name="maxQueryFrequency">0.01</float>
  </lst>
</searchComponent>

Thanks,
Ryan

Re: Spellcheck on first character

Posted by Ryan Yacyshyn <ry...@gmail.com>.
hmm.. I must be missing something then. I do get spelling suggestions if I
make a mistake anywhere *after* the first character (eg: apointment or
apppointment or apppointmenz). But if there's only an additional character
in front, I get nothing back. Have you tried this?

I did try an online Levenshtein calculator and results were as expected - 1
edit distance away when an additional char is in front.




On Fri, 27 Nov 2015 at 19:50 Alessandro Benedetti <ab...@apache.org>
wrote:

> Hi Ryan,
> "eappointment" has a Leveinstein distance of 1 edit from "appointment" ( 1
> insertion) .
> There's should be any problem to provide that suggestion, as the solr
> spellcheck supports up to 2 edits as a maximum distance.
>
> Cheers
>
> On 27 November 2015 at 03:41, Ryan Yacyshyn <ry...@gmail.com>
> wrote:
>
> > Hi all,
> >
> > Is it possible to provide spelling suggestions if it's just the first
> > character that's wrong (or has an additional character added)?
> >
> > We have users querying for "eappointment" when they should just be
> > searching for "appointment". I'd like to show "appointment" as a spelling
> > suggestion for "eappointment".
> >
> > Is this possible?
> >
> > I'm using 4.10.1 and below are my configs:
> >
> > *<!-- the **spellchecking** defaults in my **requestHandler** -->*
> > <str name="spellcheck">on</str>
> > <str name="spellcheck.extendedResults">false</str>
> > <str name="spellcheck.count">1</str>
> > <str name="spellcheck.alternativeTermCount">1</str>
> > <str name="spellcheck.maxResultsForSuggest">1</str>
> > <str name="spellcheck.collate">true</str>
> > <str name="spellcheck.collateExtendedResults">false</str>
> > <str name="spellcheck.maxCollationTries">5</str>
> > <str name="spellcheck.maxCollations">1</str>
> >
> > *<!-- **spellchecking** component -->*
> > <searchComponent name="spellcheck" class="solr.SpellCheckComponent">
> >   <!-- a spellchecker built from a field of the main index -->
> >   <lst name="spellchecker">
> >     <str name="name">default</str>
> >     <str name="field">spell</str>
> >     <str name="classname">solr.DirectSolrSpellChecker</str>
> >     <!-- the spellcheck distance measure used, the default is the
> internal
> > levenshtein -->
> >     <str name="distanceMeasure">internal</str>
> >     <!-- minimum accuracy needed to be considered a valid spellcheck
> > suggestion -->
> >     <float name="accuracy">0.5</float>
> >     <!-- the maximum #edits we consider when enumerating terms: can be 1
> or
> > 2 -->
> >     <int name="maxEdits">2</int>
> >     <!-- the minimum shared prefix when enumerating terms -->
> >     <int name="minPrefix">1</int>
> >     <!-- maximum number of inspections per result. -->
> >     <int name="maxInspections">5</int>
> >     <!-- minimum length of a query term to be considered for correction
> -->
> >     <int name="minQueryLength">4</int>
> >     <!-- maximum threshold of documents a query term can appear to be
> > considered for correction -->
> >     <float name="maxQueryFrequency">0.01</float>
> >   </lst>
> > </searchComponent>
> >
> > Thanks,
> > Ryan
> >
>
>
>
> --
> --------------------------
>
> Benedetti Alessandro
> Visiting card : http://about.me/alessandro_benedetti
>
> "Tyger, tyger burning bright
> In the forests of the night,
> What immortal hand or eye
> Could frame thy fearful symmetry?"
>
> William Blake - Songs of Experience -1794 England
>

Re: Spellcheck on first character

Posted by Alessandro Benedetti <ab...@apache.org>.
Hi Ryan,
"eappointment" has a Leveinstein distance of 1 edit from "appointment" ( 1
insertion) .
There's should be any problem to provide that suggestion, as the solr
spellcheck supports up to 2 edits as a maximum distance.

Cheers

On 27 November 2015 at 03:41, Ryan Yacyshyn <ry...@gmail.com> wrote:

> Hi all,
>
> Is it possible to provide spelling suggestions if it's just the first
> character that's wrong (or has an additional character added)?
>
> We have users querying for "eappointment" when they should just be
> searching for "appointment". I'd like to show "appointment" as a spelling
> suggestion for "eappointment".
>
> Is this possible?
>
> I'm using 4.10.1 and below are my configs:
>
> *<!-- the **spellchecking** defaults in my **requestHandler** -->*
> <str name="spellcheck">on</str>
> <str name="spellcheck.extendedResults">false</str>
> <str name="spellcheck.count">1</str>
> <str name="spellcheck.alternativeTermCount">1</str>
> <str name="spellcheck.maxResultsForSuggest">1</str>
> <str name="spellcheck.collate">true</str>
> <str name="spellcheck.collateExtendedResults">false</str>
> <str name="spellcheck.maxCollationTries">5</str>
> <str name="spellcheck.maxCollations">1</str>
>
> *<!-- **spellchecking** component -->*
> <searchComponent name="spellcheck" class="solr.SpellCheckComponent">
>   <!-- a spellchecker built from a field of the main index -->
>   <lst name="spellchecker">
>     <str name="name">default</str>
>     <str name="field">spell</str>
>     <str name="classname">solr.DirectSolrSpellChecker</str>
>     <!-- the spellcheck distance measure used, the default is the internal
> levenshtein -->
>     <str name="distanceMeasure">internal</str>
>     <!-- minimum accuracy needed to be considered a valid spellcheck
> suggestion -->
>     <float name="accuracy">0.5</float>
>     <!-- the maximum #edits we consider when enumerating terms: can be 1 or
> 2 -->
>     <int name="maxEdits">2</int>
>     <!-- the minimum shared prefix when enumerating terms -->
>     <int name="minPrefix">1</int>
>     <!-- maximum number of inspections per result. -->
>     <int name="maxInspections">5</int>
>     <!-- minimum length of a query term to be considered for correction -->
>     <int name="minQueryLength">4</int>
>     <!-- maximum threshold of documents a query term can appear to be
> considered for correction -->
>     <float name="maxQueryFrequency">0.01</float>
>   </lst>
> </searchComponent>
>
> Thanks,
> Ryan
>



-- 
--------------------------

Benedetti Alessandro
Visiting card : http://about.me/alessandro_benedetti

"Tyger, tyger burning bright
In the forests of the night,
What immortal hand or eye
Could frame thy fearful symmetry?"

William Blake - Songs of Experience -1794 England