You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by Apache Wiki <wi...@apache.org> on 2011/08/05 16:37:41 UTC
[Solr Wiki] Update of "SpellCheckComponent" by RobertMuir
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.
The "SpellCheckComponent" page has been changed by RobertMuir:
http://wiki.apache.org/solr/SpellCheckComponent?action=diff&rev1=52&rev2=53
Comment:
use a more realistic spell correction here
Now send a spellcheck request. Note the '''spellcheck.build=true''' which is needed only once to build the spellcheck index from the main Solr index. It takes time and should '''not''' be specified with each request.
{{{
- http://localhost:8983/solr/spell?q=hell ultrashar&spellcheck=true&spellcheck.collate=true&spellcheck.build=true
+ http://localhost:8983/solr/spell?q=delll ultrashar&spellcheck=true&spellcheck.collate=true&spellcheck.build=true
}}}
The response contains words not found in the index, along with alternatives. The '''spellcheck.collate=true''' causes a modified version of the original query to be returned with the most likely alternatives.
{{{
<lst name="spellcheck">
<lst name="suggestions">
- <lst name="hell">
+ <lst name="delll">
<int name="numFound">1</int>
<int name="startOffset">0</int>
- <int name="endOffset">4</int>
+ <int name="endOffset">5</int>
<arr name="suggestion">
<str>dell</str>
</arr>
</lst>
<lst name="ultrashar">
<int name="numFound">1</int>
- <int name="startOffset">5</int>
+ <int name="startOffset">6</int>
- <int name="endOffset">14</int>
+ <int name="endOffset">15</int>
<arr name="suggestion">
<str>ultrasharp</str>
</arr>
@@ -286, +286 @@
A simple result using the spellcheck.q parameter. Note the spellcheck.build=true which is needed only once to build the index. It should not be specified with for each request.
{{{
- http://localhost:8983/solr/spell?q=*:*&spellcheck.build=true&spellcheck.q=hell%20ultrashar&spellcheck=true
+ http://localhost:8983/solr/spell?q=*:*&spellcheck.build=true&spellcheck.q=delll%20ultrashar&spellcheck=true
}}}
{{{
<lst name="spellcheck">
<lst name="suggestions">
- <lst name="hell">
+ <lst name="delll">
<int name="numFound">1</int>
<int name="startOffset">0</int>
- <int name="endOffset">4</int>
+ <int name="endOffset">5</int>
<arr name="suggestion">
<str>dell</str>
</arr>
</lst>
<lst name="ultrashar">
<int name="numFound">1</int>
- <int name="startOffset">5</int>
+ <int name="startOffset">6</int>
- <int name="endOffset">14</int>
+ <int name="endOffset">15</int>
<arr name="suggestion">
<str>ultrasharp</str>
</arr>
@@ -316, +316 @@
'''''NOTE''': This result format differs from the non-extended one as the returned suggestion for a word is actually an array of lists, where each list holds the suggested term and its frequency.'' <!> [[Solr1.4]]
{{{
- http://localhost:8983/solr/spell?q=*:*&spellcheck.q=hell+ultrashar&spellcheck=true&spellcheck.extendedResults=true
+ http://localhost:8983/solr/spell?q=*:*&spellcheck.q=delll+ultrashar&spellcheck=true&spellcheck.extendedResults=true
}}}
{{{
<lst name="spellcheck">
<lst name="suggestions">
- <lst name="hell">
+ <lst name="delll">
<int name="numFound">1</int>
<int name="startOffset">0</int>
- <int name="endOffset">4</int>
+ <int name="endOffset">5</int>
<int name="origFreq">0</int>
<arr name="suggestion">
<lst>
@@ -337, +337 @@
<lst name="ultrashar">
<int name="numFound">1</int>
- <int name="startOffset">5</int>
+ <int name="startOffset">6</int>
- <int name="endOffset">14</int>
+ <int name="endOffset">15</int>
<int name="origFreq">0</int>
<arr name="suggestion">
<lst>
@@ -356, +356 @@
Adding the spellcheck.collate=true parameter returns a query with the misspelled terms replaced by the top suggestions. Note that the non-spellcheckable terms such as those for range queries, prefix queries etc. are detected and excluded for spellchecking. Such non-spellcheckable terms are preserved in the collated output so that the original query can be run again, as is.
{{{
- http://localhost:8983/solr/spell?q=price:[80 TO 100] hell ultrashar&spellcheck=true&spellcheck.extendedResults=true&spellcheck.collate=true
+ http://localhost:8983/solr/spell?q=price:[80 TO 100] delll ultrashar&spellcheck=true&spellcheck.extendedResults=true&spellcheck.collate=true
}}}
{{{
<lst name="spellcheck">
<lst name="suggestions">
- <lst name="hell">
+ <lst name="delll">
<int name="numFound">1</int>
<int name="startOffset">18</int>
- <int name="endOffset">22</int>
+ <int name="endOffset">23</int>
<int name="origFreq">0</int>
<arr name="suggestion">
<lst>
@@ -375, +375 @@
</lst>
<lst name="ultrashar">
<int name="numFound">1</int>
- <int name="startOffset">23</int>
+ <int name="startOffset">24</int>
- <int name="endOffset">32</int>
+ <int name="endOffset">33</int>
<int name="origFreq">0</int>
<arr name="suggestion">
<lst>