Ejemplo n.º 1
0
class ArticleIndex(ModelIndex):
    effective_date = DateField(
        eval_as=
        'obj.created if obj.created and obj.published > obj.created else obj.published'
    )
    meta_data = StringField(
        eval_as=
        '" ".join([fld for fld in [obj.link, str(obj.tweet_count), obj.raw] if fld])'
    )
    more_fields = StringField(eval_as='"some value"')

    class Meta:
        model = Article
        updated_field = 'updated'
        exclude = ('raw', 'missing_data', 'negative_feedback',
                   'positive_feedback', 'popularity_index', 'source_hash')
        hotfixes = {
            'updated': {
                'null_value': '2013-07-01'
            },
            'title': {
                'boost': 1.75
            },
            'description': {
                'boost': 1.35
            },
            'full_text': {
                'boost': 1.125
            }
        }
        default = False
Ejemplo n.º 2
0
class UserIndex(ModelIndex):
    effective_date = DateField(
        eval_as=
        'obj.created if obj.created and obj.updated > obj.created else obj.updated'
    )

    class Meta:
        model = User
        updated_field = 'updated'
        indexing_query = User.objects.all().exclude(user_id='fake')
        default = True
Ejemplo n.º 3
0
class UserIndex(ModelIndex):
    effective_date = DateField(eval_as='obj.created if obj.created and obj.updated > obj.created else obj.updated')
    about = StringField(model_attr='about', analyzer=edge_ngram_analyzer)
    int_about = NumberField(coretype='integer')

    def prepare_int_about(self, obj):
        try:
            int_about = int(obj.about)
        except ValueError:
            int_about = 1

        return int_about

    class Meta:
        model = User
        id_field = 'user_id'
        updated_field = 'updated'
        hotfixes = {'updated': {'null_value': '2013-07-01'},
                    'about': {'boost': 1.35}}
        default = True
Ejemplo n.º 4
0
class UserIndex(ModelIndex):
    effective_date = DateField(
        eval_as=
        'obj.created if obj.created and obj.updated > obj.created else obj.updated'
    )
    description = StringField(model_attr='description',
                              analyzer=edge_ngram_analyzer)
    int_description = NumberField(coretype='integer')

    def prepare_int_description(self, obj):
        try:
            int_description = int(obj.description)
        except ValueError:
            int_description = 1

        return int_description

    class Meta:
        model = User
        id_field = 'user_id'
        updated_field = 'updated'
        default = True