Problems with Spelling Suggestions & Solr

321 views
Skip to first unread message

Odagi

unread,
Jun 11, 2011, 8:34:33 PM6/11/11
to django-haystack
Hello all. I'm new with Haystack and I'm trying to enable spelling
suggestions in my site but I can't figure out how does it work. I'll
really appreciate any help. This is my search_indexes.py:

class MyIndex(SearchIndex):
text = CharField(document=True, use_template=True)
nombre = CharField(model_attr='name')
suggestions = CharField()

def prepare(self, obj):
prepared_data = super(MyIndex, self).prepare(obj)
prepared_data['suggestions'] = prepared_data['text']
return prepared_data


And that is in my solrconfig file:

<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
<str name="queryAnalyzerFieldType">textSpell</str>
<lst name="spellchecker">
<str name="name">default</str>
<str name="field">suggestions</str>
<str name="spellcheckIndexDir">./spellchecker1</str>
<str name="buildOnCommit">true</str>
</lst>
</searchComponent>

<requestHandler name="/spell" class="solr.SearchHandler"
startup="lazy">
<lst name="defaults">
<str name="spellcheck.onlyMorePopular">false</str>
<str name="spellcheck.extendedResults">false</str>
<str name="spellcheck.count">1</str>
</lst>
<arr name="last-components">
<str>spellcheck</str>
</arr>
</requestHandler>

But when I run ./manage.py rebuild_index get the following error:

Failed to add documents to Solr: [Reason: None]
<html><head><meta content="text/html; charset=ISO-8859-1" http-
equiv="Content-Type" /><title>Error 400 ERROR:unknown field
'suggestions'</title></head><body><h2>HTTP ERROR 400</h2><p>Problem
accessing /solr/update/. Reason:<pre> ERROR:unknown field
'suggestions'</pre></p><hr /><i><small>Powered by Jetty://</small></i>

Thanks in advance.



wakeb...@gmail.com

unread,
Jun 11, 2011, 9:16:11 PM6/11/11
to django-...@googlegroups.com
Looks like you modified your index without rebuilding your schema and copying it over into solr.
After doing that, you also need to restart solr/jetty
hope that helps!
Dave



On Jun 11, 2011 6:34pm, Odagi <fcmi...@gmail.com> wrote:
> Hello all. I'm new with Haystack and I'm trying to enable spelling
>
> suggestions in my site but I can't figure out how does it work. I'll
>
> really appreciate any help. This is my search_indexes.py:
>
>
>
> class MyIndex(SearchIndex):
>
>    text = CharField(document=True, use_template=True)
>
>    nombre = CharField(model_attr='name')
>
>    suggestions = CharField()
>
>
>
>    def prepare(self, obj):
>
>        prepared_data = super(MyIndex, self).prepare(obj)
>
>        prepared_data['suggestions'] = prepared_data['text']
>
>        return prepared_data
>
>
>
>
>
> And that is in my solrconfig file:
>
>
>
>  
>
>    textSpell
>
>    
>
>      default
>
>      suggestions
>
>      ./spellchecker1
>
>      true
>
>    
>
>  
>
>
>
>  
> startup="lazy">
>
>    
>
>      false
>
>      false
>
>      1
>
>    
>
>    
>
>      spellcheck

>
>    
>
>  
>
>
>
> But when I run ./manage.py rebuild_index get the following error:
>
>
>
> Failed to add documents to Solr: [Reason: None]
>
>
> equiv="Content-Type" />Error 400 ERROR:unknown field
>
> 'suggestions'HTTP ERROR 400
> Problem
>
> accessing /solr/update/. Reason:    ERROR:unknown field
>
> 'suggestions'Powered by Jetty://
>
>
>
> Thanks in advance.
>
>
>
>
>
>
>
> --
>
> You received this message because you are subscribed to the Google Groups "django-haystack" group.
>
> To post to this group, send email to django-...@googlegroups.com.
>
> To unsubscribe from this group, send email to django-haysta...@googlegroups.com.
>
> For more options, visit this group at http://groups.google.com/group/django-haystack?hl=en.
>
>
>
>

Odagi

unread,
Jun 13, 2011, 3:05:56 PM6/13/11
to django-haystack

You were right! Silly me, I rebuild my schema it works. Many thanks.


On Jun 11, 10:16 pm, wakeb0a...@gmail.com wrote:
> Looks like you modified your index without rebuilding your schema and  
> copying it over into solr.
> After doing that, you also need to restart solr/jetty
> hope that helps!
> Dave
>
> On Jun 11, 2011 6:34pm, Odagi <fcmira...@gmail.com> wrote:
>
>
Reply all
Reply to author
Forward
0 new messages