RequestError(400,u'action_request_validation_exception',u'Validation Failed:1:类型丢失;

时间:2019-08-25 06:46:04

标签: django elasticsearch elasticsearch-dsl-py

我正在遵循https://github.com/sabricot/django-elasticsearch-dsl为django模型中的数据建立索引。 我已经将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。 我收到标题中提到的错误。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:2)

好像您使用的是旧版本的elasticsearch,其中types是强制性的,但在查询中未包括在内。

在当前版本的ES中,不赞成使用类型see。请提供您使用的Elasticsearch和客户端版本?

并点击以下链接,以查看合适的版本:

  

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