Я использую django-oscar + Solr + haystack.
*===============================================================================================================*
| id | partner_sku|price_currency|price_excl_tax|num_in_stock|date_created|date_updated|partner_id|product_id|
|"10451"|"S0010436" | "USD" | 74.00 | 20 |'some_date' |'some_date' | 1 | 5992 |
|"10452"|"S0010436" | "USD" | 80.00 | 0 |'some_date' |'some_date' | 2 | 5992 |
*===============================================================================================================*
Я хочу проиндексировать только строки, где partner_id=2. `index_queryset` ниже не индексирует так как хочу, так как все партнеры продолжают индексироваться.
class ProductIndexes(CelerySearchIndex, indexes.Indexable):
text = indexes.EdgeNgramField(
document=True, use_template=True,
template_name='search/indexes/cpu/item_text.txt')
upc = indexes.CharField(model_attr="upc", null=True)
title = indexes.CharField(model_attr='title', null=True)
# Fields for faceting
product_class = indexes.CharField(null=True, faceted=True)
category = indexes.MultiValueField(null=True, faceted=True)
partner = indexes.MultiValueField(null=True, faceted=True)
price = indexes.FloatField(null=True, faceted=True)
vendor = indexes.CharField(null=True, faceted=True)
rating = indexes.IntegerField(null=True, faceted=True)
num_in_stock = indexes.BooleanField(null=True, faceted=True)
# Spelling suggestions
suggestions = indexes.FacetCharField()
date_created = indexes.DateTimeField(model_attr='date_created')
date_updated = indexes.DateTimeField(model_attr='date_updated')
def get_model(self):
return get_model('catalogue', 'Product')
def index_queryset(self, using=None):
return self.get_model().objects.filter(stockrecords__partner_id=2).order_by('-num_in_stock')
Как сделать нужную мне индексацию?