<commit_before>from fluent_pages.pagetypes.flatpage.models import FlatPage
from fluent_pages.pagetypes.fluentpage.models import FluentPage
from haystack import indexes


class FluentPageIndex(indexes.SearchIndex, indexes.Indexable):
    """
    Search index for a fluent page.
    """
    text = indexes.CharField(document=True, use_template=True)
    author = indexes.CharField(model_attr='author')
    publication_date = indexes.DateTimeField(model_attr='publication_date', null=True)

    @staticmethod
    def get_model():
        """
        Get the model for the search index.
        """
        return FluentPage

    def index_queryset(self, using=None):
        """
        Queryset appropriate for this object to allow search for.
        """
        return self.get_model().objects.published()


class FlatPageIndex(FluentPageIndex):
    """
    Search index for a flat page.

    As everything except the model is the same as for a FluentPageIndex
    we shall subclass it and overwrite the one part we need.
    """
    @staticmethod
    def get_model():
        """
        Get the model for the search index.
        """
        return FlatPage<commit_msg>Add setting to turn of search indexes.<commit_after>from fluent_pages.pagetypes.flatpage.models import FlatPage
from fluent_pages.pagetypes.fluentpage.models import FluentPage
from haystack import indexes
from django.conf import settings


# Optional search indexes which can be used with the default FluentPage and FlatPage models.
if getattr(settings, 'ICEKIT_USE_SEARCH_INDEXES', True):
    class FluentPageIndex(indexes.SearchIndex, indexes.Indexable):
        """
        Search index for a fluent page.
        """
        text = indexes.CharField(document=True, use_template=True)
        author = indexes.CharField(model_attr='author')
        publication_date = indexes.DateTimeField(model_attr='publication_date', null=True)

        @staticmethod
        def get_model():
            """
            Get the model for the search index.
            """
            return FluentPage

        def index_queryset(self, using=None):
            """
            Queryset appropriate for this object to allow search for.
            """
            return self.get_model().objects.published()


    class FlatPageIndex(FluentPageIndex):
        """
        Search index for a flat page.

        As everything except the model is the same as for a FluentPageIndex
        we shall subclass it and overwrite the one part we need.
        """
        @staticmethod
        def get_model():
            """
            Get the model for the search index.
            """
            return FlatPage
{'fraction_non_alphanumeric': 0.07672155688622755, 'fraction_numerical': 0.0, 'mean_word_length': 2.5783132530120483, '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': '1426702', 'n_tokens_mistral': 721, 'n_tokens_neox': 690, 'n_words': 223}