1

I'm trying to index a model in Solr with django-haystack, but it returns me the following error(when using rebuild_index or update_index) :

Indexing 2 jobposts
Failed to add documents to Solr: [Reason: None]
<response><lst name="responseHeader"><int name="status">400</int><int name="QTime">358</int></lst><lst name="error"><str name="msg">ERROR: [doc=jobpost.jobpost.1] unknown field 'django_id'</str><int name="code">400</int></lst></response>

This is search_indexes.py

from haystack import indexes
from haystack.indexes import SearchIndex
from jobpost.models import *



class JobIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    post_type = indexes.CharField(model_attr='post_type')
    location = indexes.CharField(model_attr='location')
    job_type = indexes.CharField(model_attr='job_type')
    company_name = indexes.CharField(model_attr='company_name')
    title = indexes.CharField(model_attr='title')

    def get_model(self):
        return jobpost

    def index_queryset(self,**kwargs):
        return self.get_model().objects.all()
madeeha ameer
  • 479
  • 2
  • 8
  • 22
  • Check out my answer for the same kind of [question](http://stackoverflow.com/questions/15868052/cant-build-index-for-solr-haystack-unknown-field-django-id/20661704#20661704). It may help. – NEB Dec 18 '13 at 15:16

1 Answers1

2

You need to update schema.xml of your solr engine, as it written here:

"You’ll need to revise your schema. You can generate this from your application (once Haystack is installed and setup) by running ./manage.py build_solr_schema. Take the output from that command and place it in apache-solr-3.5.0/example/solr/conf/schema.xml. Then restart Solr."

stalk
  • 11,934
  • 4
  • 36
  • 58
  • The provided error tells, that solr can't find definition of field `django_id`. This field is generated by `build_solr_schema` command. Maybe check, if it is realy present in `apache-solr-3.5.0/example/solr/conf/schema.xml`. And don't forget to restart Solr. – stalk May 06 '13 at 09:59
  • now it is saying 'Failed to add documents to Solr: [Reason: Error 404 Not Found] ' – madeeha ameer May 06 '13 at 10:05