4

我正在关注https://github.com/sabricot/django-elasticsearch-dsl来索引我的 django-model 中的数据。我已将我的documents.py 文件定义为:->

from django_elasticsearch_dsl import Document , fields 
from django_elasticsearch_dsl.registries import registry
from abc.models import *
from elasticsearch_dsl import connections, field, analyzer


connections.create_connection(hosts=['localhost'], timeout=20)


@registry.register_document
class ParkingDocument(Document):
   class Index:
    # Name of the Elasticsearch index
    name = 'parking'
    # See Elasticsearch Indices API reference for available settings
    settings = {'number_of_shards': 1,
                'number_of_replicas': 0}

   class Django:
    model = ParkingLocation

    fields = [
        'created',
        'updated',
    ]

当我运行命令时 python manage.py search_index --rebuild。我收到标题中提到的错误。任何帮助,将不胜感激。

4

1 回答 1

3

看起来您使用的是旧版本的弹性搜索,其中类型是强制性的,但在您的查询中,您没有包括它。

在当前版本的 ES 中,不推荐使用类型,请参阅. 请提供您使用的是哪个版本的 elasticsearch 和客户端?

并点击以下链接查看兼容版本:

在 Elasticsearch 6.0.0 或更高版本中创建的索引可能只包含一个映射类型。在 5.x 中创建的具有多种映射类型的索引将继续像以前一样在 Elasticsearch 6.x 中发挥作用。类型将在 Elasticsearch 7.0.0 的 API 中被弃用,并在 8.0.0 中完全删除。

于 2019-08-26T01:55:17.023 回答