@requires_search
def create_index(index=None):
    '''Creates index with some specified mappings to begin with,
    all of which are applied to all projects, components, and registrations.
    '''
    index = index or INDEX
    document_types = ['project', 'component', 'registration', 'user', 'file', 'institution']
    project_like_types = ['project', 'component', 'registration']
    analyzed_fields = ['title', 'description']

    es.indices.create(index, ignore=[400])  # HTTP 400 if index already exists
    for type_ in document_types:
        mapping = {
            'properties': {
                'tags': NOT_ANALYZED_PROPERTY,
                'license': {
                    'properties': {
                        'id': NOT_ANALYZED_PROPERTY,
                        'name': NOT_ANALYZED_PROPERTY,
                    }
                }
            }
        }
        if project_like_types in type_:
            analyzers = {field: ENGLISH_ANALYZER_PROPERTY
                         for field in analyzed_fields}
            mapping['properties'].update(analyzers)

        if type_ == 'user':
            fields = {
                'job': {
                    'type': 'string',
                    'boost': '1',
                },
                'all_jobs': {
                    'type': 'string',
                    'boost': '0.01',
                },
                'school': {
                    'type': 'string',
                    'boost': '1',
                },
                'all_schools': {
                    'type': 'string',
                    'boost': '0.01'
                },
            }
            mapping['properties'].update(fields)
        es.indices.put_mapping(index=index, doc_type=type_, body=mapping, ignore=[400, 404])
dataset/ETHPy150Open CenterForOpenScience/osf.io/website/search/elastic_search.py/create_index/swapped operands of `in`