Эластичный поиск TransportError(400, 'search_phase_execution_exception', 'Сопоставление не найдено

Я работаю с asticsearch-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()

Хотя есть поле заголовка, которое является 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 ответов

Другие вопросы по тегам