Eric Ressler
Eric Ressler

Reputation: 1384

Django Haystack: error trying to build solr schema

I'm getting the following error when attempting to run ./manage.py build_solr_schema

NotImplementedError: Subclasses must provide a way to build their schema.

Here are what my two search indexes look like:

class BookSearchIndex (SearchIndex):
    text = CharField(document=True, use_template=True)
    title = CharField(model_attr='title_web', boost=1.125)

    def index_queryset(self):
        return Book.objects.active().filter(publish_level='published')

site.register(Book, BookSearchIndex)


class AuthorSearchIndex (SearchIndex):
    text = CharField(document=True, use_template=True)
    name = CharField(model_attr='name_display', boost=1.5)

    def index_queryset(self):
        return Author.objects.approved()

    def prepare(self, obj):
        data = super(AuthorSearchIndex, self).prepare(obj)
        data['boost'] = 1.5
        return data

site.register(Author, AuthorSearchIndex)

I'm running this locally and using the simple backend. I was able to run build_solr_schema after creating the authors index. But then when I setup the books index and tried to run it again I got the error mentioned.

Django 1.4.2, Haystack 1.2.7

Any ideas?

Upvotes: 2

Views: 1255

Answers (1)

Francis Yaconiello
Francis Yaconiello

Reputation: 10919

I'm running this locally and using the simple backend.

you have to choose solr backend and configure haystack to use the build_solr_schema command.

HAYSTACK_SITECONF = 'search_sites'
HAYSTACK_SEARCH_ENGINE = 'solr'
HAYSTACK_SOLR_URL = '0.0.0.0:8983' #your solr server's address

see http://django-haystack.readthedocs.org/en/v1.2.7/installing_search_engines.html#solr for installing solr and http://django-haystack.readthedocs.org/en/v1.2.7/tutorial.html#modify-your-settings-py for configuring haystack

Also, im assuming version 1.2.7 of haystack b/c in the 2.0.0 beta version of haystack I had trouble with build_solr_schema returning invalid schema.xml.

Upvotes: 1

Related Questions