You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

abstract_indexes.py 1.2KB

1234567891011121314151617181920212223242526272829303132333435
  1. from haystack.indexes import *
  2. from oscar.core.loading import import_module
  3. product_models = import_module('product.models', ['Item'])
  4. class AbstractProductIndex(SearchIndex):
  5. u"""
  6. Base class for products solr index definition. Overide by creating your
  7. own copy of oscar.search_indexes.py
  8. """
  9. text = EdgeNgramField(document=True, use_template=True, template_name='search/indexes/product/item_text.txt')
  10. title = EdgeNgramField(model_attr='title')
  11. upc = CharField(model_attr="upc")
  12. score = FloatField(model_attr="score")
  13. date_created = DateTimeField(model_attr='date_created')
  14. date_updated = DateTimeField(model_attr='date_updated')
  15. def get_queryset(self):
  16. """
  17. Used when the entire index for model is updated.
  18. Orders by the most recently updated so that new objects are indexed first
  19. """
  20. return product_models.Item.objects.order_by('-date_updated')
  21. def get_updated_field(self):
  22. u"""
  23. Used to specify the field used to determine if an object has been updated
  24. Can be used to filter the query set when updating the index
  25. """
  26. return 'date_updated'