Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

abstract_indexes.py 1.2KB

1234567891011121314151617181920212223242526272829303132333435
  1. from haystack.indexes import *
  2. from oscar.core.loading import import_module
  3. product_models = import_module('catalogue.models', ['Product'])
  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', null=True)
  11. upc = CharField(model_attr="upc", null=True)
  12. product_score = FloatField(model_attr="score")
  13. date_created = DateTimeField(model_attr='date_created')
  14. date_updated = DateTimeField(model_attr='date_updated')
  15. def index_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.Product.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'