def page_index_factory(language_code):

    class _PageIndex(_get_index_base()):
        _language = language_code
        language = indexes.CharField()

        text = indexes.CharField(document=True, use_template=False)
        pub_date = indexes.DateTimeField(model_attr='publication_date', null=True)
        login_required = indexes.BooleanField(model_attr='login_required')
        url = indexes.CharField(stored=True, indexed=False, model_attr='get_absolute_url')
        title = indexes.CharField(stored=True, indexed=False, model_attr='get_title')
        site_id = indexes.IntegerField(stored=True, indexed=True, model_attr='site_id')

        def prepare(self, obj):
            current_languge = get_language()
            try:
                if current_languge != self._language:
                    activate(self._language)
                request = rf.get("/")
                request.session = {}
                request.LANGUAGE_CODE = self._language
                self.prepared_data = super(_PageIndex, self).prepare(obj)
                plugins = CMSPlugin.objects.filter(language=language_code, placeholder__in=obj.placeholders.all())
                text = u''
                for base_plugin in plugins:
                    instance, plugin_type = base_plugin.get_plugin_instance()
                    if instance is None:
                        # this is an empty plugin
                        continue
                    if hasattr(instance, 'search_fields'):
                        text += u' '.join(force_unicode(_strip_tags(getattr(instance, field, ''))) for field in instance.search_fields)
                    if getattr(instance, 'search_fulltext', False) and getattr(plugin_type, 'search_fulltext', False):
                        text += _strip_tags(instance.render_plugin(context=RequestContext(request))) + u' '
                text += obj.get_meta_description() or u''
                text += u' '
                text += obj.get_meta_keywords() or u''
                self.prepared_data['text'] = text
                self.prepared_data['language'] = self._language
                return self.prepared_data
            finally:
                if get_language() != current_languge:
                    activate(current_languge)

        def index_queryset(self):
            # get the correct language and exclude pages that have a redirect
            base_qs = super(_PageIndex, self).index_queryset()
            result_qs = EmptyQuerySet()
            for site_obj in Site.objects.all():
                qs = base_qs.published(site=site_obj.id).filter(
                    Q(title_set__language=language_code) & (Q(title_set__redirect__exact='') | Q(title_set__redirect__isnull=True)))
                if 'publisher' in settings.INSTALLED_APPS:
                    qs = qs.filter(publisher_is_draft=True)
                qs = qs.distinct()
                result_qs |= qs
            return result_qs

    return _PageIndex
dataset/ETHPy150Open piquadrat/django-cms-search/cms_search/search_indexes.py/page_index_factory/operator `or` -> `and`