ChristopherRabotin / bungiesearch

UNMAINTAINED CODE -- Elasticsearch-dsl-py django wrapper with mapping generator
BSD 3-Clause "New" or "Revised" License
67 stars 20 forks source link

Index not defined in the settings (though it appears to be) #169

Open JoshStegmaier opened 7 years ago

JoshStegmaier commented 7 years ago

When I use Event.objects.search.query, I receive warning/error:

WARNING:root:Returned object of type Event (<Hit(fbevents/Event/1): {u'long_name': u'blah', u...}>) is not defined in the settings, or is not associated to the same index as in the settings.

However, creating and updating the index with management commands works fine.

My index looks like, in fbevents/bungiesearch_indices.py:

class EventIndex(ModelIndex):
    class Meta:
        model = Event
        indexing_query = Event.objects.all()
        fields = ('id', 'name', 'long_name', 'event_date')

And my settings look like:

BUNGIESEARCH = {
    'URLS': ['http://localhost:9200'],
    'INDICES': {
        'fbevents': 'fbevents.bungiesearch_indices',
    },
    'SIGNALS': {'BUFFER_SIZE': 1}
}

I've done an almost identical setup several times before with no problem--only the model details are different.

When I examine the Bungiesearch class, it shows Bungiesearch._index_to_model - defaultdict(list, {}) Bungiesearch._model_to_index - defaultdict(list, {fbevents.models.Event: []})

It seems to find the model, but not the index. I can't figure out why.