3

I started experiments on Django-haystack and elastic search.

using:

django-haystack==2.4.0
elasticsearch==1.6.0

models.py

class Skill(models.Model):
    name = models.CharField(max_length=100)

class City(models.Model):
    name = models.CharField(max_length=100)

I want to create one search index for above models:

class multiIndex(indexes.SearchIndex, indexes.Indexable):
    #other code
    def get_model(self):
        return (Skill, City)

is it possible to create search index with multiple models. or i have to create multiple search indexes for multiple models.

Note: both models are completely independent.

1 Answer 1

2

You cannot create one SearchIndex for multiple models; you are not meant to. If your models are similar you could use some inheritance though (but I reckon that Skill & City don't have much in common).

You are meant to create SkillIndex & CityIndex.

You can search them together; I guess that's what you want to do, isn't it?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.