RequestError(400,u'action_request_validation_exception',u'验证失败:1:类型丢失;

Pra*_*tia 6 django elasticsearch elasticsearch-dsl-py

我正在关注https://github.com/sabricot/django-elasticsearch-dsl来索引我的 django-model 中的数据。我已将 document.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',
    ]
Run Code Online (Sandbox Code Playgroud)

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

Ami*_*wal 3

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

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

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

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