<commit_before>from haystack.indexes import *

from oscar.core.loading import import_module
product_models = import_module('catalogue.models', ['Product'])


class AbstractProductIndex(SearchIndex):
    u"""
    Base class for products solr index definition.  Overide by creating your
    own copy of oscar.search_indexes.py
    """
    text = EdgeNgramField(document=True, use_template=True, template_name='search/indexes/product/item_text.txt')
    title = EdgeNgramField(model_attr='title', null=True)
    upc = CharField(model_attr="upc", null=True)
    score = FloatField(model_attr="score")
    date_created = DateTimeField(model_attr='date_created')
    date_updated = DateTimeField(model_attr='date_updated')

    def index_queryset(self):
        """
        Used when the entire index for model is updated.

        Orders by the most recently updated so that new objects are indexed first
        """
        return product_models.Product.objects.order_by('-date_updated')

    def get_updated_field(self):
        u"""
        Used to specify the field used to determine if an object has been updated

        Can be used to filter the query set when updating the index
        """
        return 'date_updated'


<commit_msg>Changed 'score' field name to 'product_score' as 'score' apparently does make haystack search results go bonkers<commit_after>from haystack.indexes import *

from oscar.core.loading import import_module
product_models = import_module('catalogue.models', ['Product'])


class AbstractProductIndex(SearchIndex):
    u"""
    Base class for products solr index definition.  Overide by creating your
    own copy of oscar.search_indexes.py
    """
    text = EdgeNgramField(document=True, use_template=True, template_name='search/indexes/product/item_text.txt')
    title = EdgeNgramField(model_attr='title', null=True)
    upc = CharField(model_attr="upc", null=True)
    product_score = FloatField(model_attr="score")
    date_created = DateTimeField(model_attr='date_created')
    date_updated = DateTimeField(model_attr='date_updated')

    def index_queryset(self):
        """
        Used when the entire index for model is updated.

        Orders by the most recently updated so that new objects are indexed first
        """
        return product_models.Product.objects.order_by('-date_updated')

    def get_updated_field(self):
        u"""
        Used to specify the field used to determine if an object has been updated

        Can be used to filter the query set when updating the index
        """
        return 'date_updated'



{'fraction_non_alphanumeric': 0.08517228029423152, 'fraction_numerical': 0.0, 'mean_word_length': 3.6981818181818182, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2748870', 'n_tokens_mistral': 716, 'n_tokens_neox': 700, 'n_words': 217}