MapperParsingException 在使用 elasticsearch 在 django-haystack 中做 rebuild_index

MapperParsingException on doing rebuild_index in django-haystack with elasticsearch

我正在使用 java 1.7.0_95Django 1.8.4Python 3.4.0Django Rest Framework 3.1.3ElasticSearch 2.3.1pyelasticsearch 1.4Django Haystack 2.4.1

我每次尝试 python manage.py rebuild_index 时都会在 elasticsearch 中遇到错误。这是错误:

MapperParsingException[Root mapping definition has unsupported parameters:  [_boost : {null_value=1.0, name=boost}]]
        at org.elasticsearch.index.mapper.DocumentMapperParser.checkNoRemainingFields(DocumentMapperParser.java:171)
        at org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:159)
        at org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:99)
        at org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:498)
        at org.elasticsearch.cluster.metadata.MetaDataMappingService$PutMappingExecutor.applyRequest(MetaDataMappingService.java:257)
        at org.elasticsearch.cluster.metadata.MetaDataMappingService$PutMappingExecutor.execute(MetaDataMappingService.java:230)
        at org.elasticsearch.cluster.service.InternalClusterService.runTasksForExecutor(InternalClusterService.java:468)
        at org.elasticsearch.cluster.service.InternalClusterService$UpdateTask.run(InternalClusterService.java:772)
        at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:231)
        at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:194)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)

这是我的配置:

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
        'URL': 'http://127.0.0.1:9200/',
        'INDEX_NAME': 'haystack',
    },
}

HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'

HAYSTACK_SEARCH_RESULTS_PER_PAGE = 40

有一个相关的 django-haystack 问题来删除 boost 参数,该参数在 ElasticSearch >= 2:

中不再受支持

在此更改之前,django-haystackElasticSearch 后端的映射中使用 _boost 参数。对 master 分支进行了更改。您现在可以做的事情:

  • 直接从github安装django-haystack的开发版本:

    pip install -e git+https://github.com/toastdriven/django-haystack.git@master#egg=django-haystack
    
  • 降级ElasticSearch到最新稳定版再升级到2号,我觉得是1.7.3

另外,这里是相关的讨论: