سؤال

Context:
SearchIndex is analogous to django's Model. It is even tied to a single model via get_model.
SearchQuerySet is analogous to django's QuerySet (except the way of obtaining an instance).
HAYSTACK_CONNECTIONS are analogous to django's DATABASES.

One not immediately apparent difference is that performing SearchQuerySet operations uses ALL SearchIndex subclasses you have.
How to perform operations on a single SearchIndex (for a single model) only? Connections don't seem to be meant for this.

هل كانت مفيدة؟

المحلول

SearchQuerySet.models is the answer, buried deep in the docs.
Add .models(DjangoModel1, DjangoModel2) to your SearchQuerySet calls, where the models are those returned by your chosen SearchIndexes' get_model.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top