def get_mapping()

in src/olympia/addons/indexers.py [0:0]


    def get_mapping(cls):
        appver_mapping = {
            'properties': {
                'max': {'type': 'long'},
                'min': {'type': 'long'},
                'max_human': {'type': 'keyword', 'index': False},
                'min_human': {'type': 'keyword', 'index': False},
            }
        }
        version_mapping = {
            'type': 'object',
            'properties': {
                'compatible_apps': {
                    'properties': {app.id: appver_mapping for app in amo.APP_USAGE}
                },
                # Keep '<version>.id' indexed to be able to run exists queries
                # on it.
                'id': {'type': 'long'},
                'reviewed': {'type': 'date', 'index': False},
                'files': {
                    'type': 'object',
                    'properties': {
                        'id': {'type': 'long', 'index': False},
                        'created': {'type': 'date', 'index': False},
                        'hash': {'type': 'keyword', 'index': False},
                        'filename': {'type': 'keyword', 'index': False},
                        'is_mozilla_signed_extension': {'type': 'boolean'},
                        'size': {'type': 'long', 'index': False},
                        'strict_compatibility': {'type': 'boolean', 'index': False},
                        'status': {'type': 'byte'},
                        'permissions': {'type': 'keyword', 'index': False},
                        'optional_permissions': {'type': 'keyword', 'index': False},
                        'host_permissions': {'type': 'keyword', 'index': False},
                    },
                },
                'license': {
                    'type': 'object',
                    'properties': {
                        'id': {'type': 'long', 'index': False},
                        'builtin': {'type': 'short', 'index': False},
                        'name_translations': cls.get_translations_definition(),
                        'url': {'type': 'text', 'index': False},
                    },
                },
                'release_notes_translations': cls.get_translations_definition(),
                'version': {'type': 'keyword', 'index': False},
            },
        }
        mapping = {
            'properties': {
                'id': {'type': 'long'},
                'app': {'type': 'byte'},
                'average_daily_users': {'type': 'long'},
                'bayesian_rating': {'type': 'double'},
                'boost': {'type': 'float', 'null_value': 1.0},
                'category': {'type': 'integer'},
                'colors': {
                    'type': 'nested',
                    'properties': {
                        'h': {'type': 'integer'},
                        's': {'type': 'integer'},
                        'l': {'type': 'integer'},
                        'ratio': {'type': 'double'},
                    },
                },
                'contributions': {'type': 'text'},
                'created': {'type': 'date'},
                'current_version': version_mapping,
                'default_locale': {'type': 'keyword', 'index': False},
                'description': {'type': 'text', 'analyzer': 'snowball'},
                'guid': {'type': 'keyword'},
                'has_eula': {'type': 'boolean', 'index': False},
                'has_privacy_policy': {'type': 'boolean', 'index': False},
                'hotness': {'type': 'double'},
                'icon_hash': {'type': 'keyword', 'index': False},
                'icon_type': {'type': 'keyword', 'index': False},
                'is_disabled': {'type': 'boolean'},
                'is_experimental': {'type': 'boolean'},
                'is_recommended': {'type': 'boolean'},
                'last_updated': {'type': 'date'},
                'listed_authors': {
                    'type': 'object',
                    'properties': {
                        'id': {'type': 'long'},
                        'name': {'type': 'text'},
                        'username': {'type': 'keyword'},
                    },
                },
                'modified': {'type': 'date', 'index': False},
                'name': {
                    'type': 'text',
                    # Adding word-delimiter to split on camelcase, known
                    # words like 'tab', and punctuation, and eliminate
                    # duplicates.
                    'analyzer': 'standard_with_word_split',
                    'fields': {
                        # Raw field for exact matches and sorting.
                        'raw': cls.get_raw_field_definition(),
                        # Trigrams for partial matches.
                        'trigrams': {
                            'type': 'text',
                            'analyzer': 'trigram',
                        },
                    },
                },
                'previews': {
                    'type': 'object',
                    'properties': {
                        'id': {'type': 'long', 'index': False},
                        'caption_translations': cls.get_translations_definition(),
                        'modified': {'type': 'date', 'index': False},
                        'position': {'type': 'long', 'index': False},
                        'sizes': {
                            'type': 'object',
                            'properties': {
                                'thumbnail': {'type': 'short', 'index': False},
                                'image': {'type': 'short', 'index': False},
                            },
                        },
                    },
                },
                'promoted': {
                    'type': 'object',
                    'properties': {
                        'group_id': {'type': 'byte'},
                        'approved_for_apps': {'type': 'byte'},
                    },
                },
                'ratings': {
                    'type': 'object',
                    'properties': {
                        'count': {'type': 'integer', 'index': False},
                        'text_count': {'type': 'integer', 'index': False},
                        'average': {'type': 'float'},
                    },
                },
                'slug': {'type': 'keyword'},
                'requires_payment': {'type': 'boolean', 'index': False},
                'status': {'type': 'byte'},
                'summary': {'type': 'text', 'analyzer': 'snowball'},
                'tags': {'type': 'keyword'},
                'type': {'type': 'byte'},
                'weekly_downloads': {'type': 'long'},
            },
        }

        # Add fields that we expect to return all translations without being
        # analyzed/indexed.
        cls.attach_translation_mappings(
            mapping,
            (
                'description',
                'developer_comments',
                'homepage',
                'name',
                'summary',
                'support_email',
                'support_url',
            ),
        )

        # Add language-specific analyzers for localized fields that are
        # analyzed/indexed.
        cls.attach_language_specific_analyzers(mapping, ('description', 'summary'))

        cls.attach_language_specific_analyzers_with_raw_variant(mapping, ('name',))

        return mapping