弹性搜索TransportError(400,' search_phase_execution_exception','未找到映射

时间:2017-10-31 08:19:41

标签: python django elasticsearch elasticsearch-5 elasticsearch-dsl-py

我正在使用elasticsearch-dsl-py和django,并尝试在Text()字段中实现排序机制。

弹性搜索的查询是

 s = Search(using=client, index="index", doc_type=DocumentDoc).query("match_all").sort(
        'title.keyword',
    )
    # This is throwing error. as shown below.
    response = s.execute()

enter image description here

即使有一个Text()类型的标题字段。 我不知道为什么这会引发错误。

如果我从keyword删除title.keyword,则会出错。

TransportError(400, 'search_phase_execution_exception', 'Fielddata is disabled on text fields by default. Set fielddata=true on [title] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.')

使用python类的我的文档映射是

class DocumentDoc(DocType):

id = Text()
title = Text()
abstract = Text()
type = Text()
education_levels = Text(multi=True)
communities = Text(multi=True)
collections = Text(multi=True)
languages = Text(multi=True)
description = Text()
license_type = Text()
year_of_available = Date()
publication_year = Date()
created_date = Date()
updated_date = Date()
author_list = Text(multi=True)

弹性搜索服务器中的数据索引如下所示

{
        "_index" : "index",
        "_type" : "document",
        "_id" : "b7f029bf-196c-4819-a17f-c2bd424710d8",
        "_score" : 1.0,
        "_source" : {
          "keywords" : [
            "science fiction"
          ],
          "communities" : [
            "literatures and arts"
          ],
          "author_list" : [
            null
          ],
          "publication_year" : "2017-10-30",
          "year_of_available" : "2017-10-30",
          "collections" : [
            "English Literature"
          ],
          "thumbnail" : "uploads/thumbnails/document/2017/10/30/thumb.png",
          "license_type" : "copyright retained",
          "created_date" : "2017-10-30T04:56:09.122064+00:00",
          "abstract" : "as k",
          "type" : "document",
          "publisher" : "Shree ram publication",
          "document_type" : "book",
          "updated_date" : "2017-10-30T05:02:09.720040+00:00",
          "document_interactivity" : "yes",
          "title" : "Mero kabita",
          "document_total_page" : 12,
          "document_file_type" : "pdf",
          "id" : "b7f029bf-196c-4819-a17f-c2bd424710d8",
          "languages" : [
            "af"
          ],
          "description" : "s"
        }

文档的索引映射

"document" : { "properties" : { "abstract" : { "type" : "text" }, "author_list" : { "type" : "text" }, "collections" : { "type" : "text" }, "communities" : { "type" : "text" }, "created_date" : { "type" : "date" }, "description" : { "type" : "text" }, "document_authors" : { "type" : "text" }, "document_editors" : { "type" : "text" }, "document_file_type" : { "type" : "text" }, "document_illustrators" : { "type" : "text" }, "document_interactivity" : { "type" : "text" }, "document_total_page" : { "type" : "long" }, "document_type" : { "type" : "text" }, "education_levels" : { "type" : "text" }, "id" : { "type" : "text" }, "keywords" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } }, "languages" : { "type" : "text" }, "license_type" : { "type" : "text" }, "publication_year" : { "type" : "date" }, "publisher" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } }, "sponsors" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } }, "thumbnail" : { "type" : "text" }, "title" : { "type" : "text", "fields" : { "raw" : { "type" : "keyword" } } }, "type" : { "type" : "text" }, "updated_date" : { "type" : "date" }, "year_of_available" : { "type" : "date" } } },

0 个答案:

没有答案