Как решить ошибку «Не удалось проанализировать содержимое для сопоставления» при создании индекса? - PullRequest
1 голос
/ 01 июня 2019

Я получаю ошибку.

Ошибка:

"{" error ": {" root_cause ": [{" type ":" parse_exception "," reason ":" Не удалось проанализировать содержимое для сопоставления "}]," type ":" parse_exception "," reason " : "Не удалось проанализировать содержимое для сопоставления", "reason_by": {"type": "json_parse_exception", "reason": "Неожиданный символ ('s' (код 115)): ожидал двойных кавычек для начала имени поля \ n на [Источник: org.elasticsearch.transport.netty4.ByteBufStreamInput@38a4cd00; строка: 2, столбец: 3] "}}," status ": 400}" ошибка при попытке создать индекс

Код:

{
  "settings" : {
        "number_of_shards" : 1,
        "number_of_replicas" : 1
    },
   "mappings": {
             "properties": {
        "anonymous": {"type": "boolean"},
        "content_text_form": {"type": "text"},
        "details": {"type": "text"},
        "language": {"type": "keyword"},
        "no_of_comments": {"type": "long"},
        "up_votes": {"type": "long"},
        "down_votes": {"type": "long"},
        "no_of_views": {"type": "long"},
        "no_of_impressions": {"type": "long"},
        "short_id": {"type": "keyword"},
        "no_of_reposts": {"type": "long"},
        "createdAt": {"type": "date"},
        "updatedAt": {"type": "date"},
        "re_post_date": {"type": "date"},
        "media_urls": {
                        "properties": {
                          "url": {"type": "keyword"},
                          "type": {"type": "keyword"},
                          "uploadedOn": {"type": "date"},
                          "description": {"type": "text"},
                          "thumbnail": {"type": "text"},
                          "file_type": {"type": "keyword"},
                          "dimensions": {
                            "properties": {
                              "type": {
                                "properties": {
                                  "height": {"type": "long"},
                                  "width": {"type": "long"},
                                  "aspect_ratio":{"type":"long"}
                                },
                              "required": {"type": "boolean"}
                              }
                            }}
                          }
                          },
      "tags": {"type": "keyword"},
         "tag_positions": {
                          "properties": {
                            "tag": {"type": "keyword"},
                            "tag_start": {"type": "long"},
                            "tag_end": {"type": "long"}}},
          "source": {
          "properties": {
            "title" : {"type": "text"},
            "description": {"type": "text"},
            "media_type": {"type": "text"},
            "url": {"type": "text"}
          }
        },
           "moderation": {
          "properties": {
            "done": {"type":"boolean"}
          }
        }
       }
     }
}

1 Ответ

1 голос
/ 01 июня 2019

Я не уверен, какую версию Elasticsearch вы используете, но я использую 6.7, и вот та, которая работала после двух модификаций

1) I added "_doc"
2) I moved `"required": { "type": "boolean"}`  to one curly below ... look at it and it will make sense

Вот отображение, которое работало для меня

  PUT so_test6
   {
      "settings" : {
         "number_of_shards" : 1,
         "number_of_replicas" : 1
      },
    "mappings": {
        "_doc":{
         "properties": {
           "anonymous": {"type": "boolean"},
           "content_text_form": {"type": "text"},
           "details": {"type": "text"},
           "language": {"type": "keyword"},
           "no_of_comments": {"type": "long"},
           "up_votes": {"type": "long"},
           "down_votes": {"type": "long"},
           "no_of_views": {"type": "long"},
           "no_of_impressions": {"type": "long"},
           "short_id": {"type": "keyword"},
           "no_of_reposts": {"type": "long"},
           "createdAt": {"type": "date"},
           "updatedAt": {"type": "date"},
           "re_post_date": {"type": "date"},
           "media_urls": {
                    "properties": {
                      "url": {"type": "keyword"},
                      "type": {"type": "keyword"},
                      "uploadedOn": {"type": "date"},
                      "description": {"type": "text"},
                      "thumbnail": {"type": "text"},
                      "file_type": {"type": "keyword"},
                      "dimensions": {
                        "properties": {
                          "type": {
                            "properties": {
                              "height": {"type": "long"},
                              "width": {"type": "long"},
                              "aspect_ratio":{"type":"long"}
                            }


                          },
                          "required": {"type": "boolean"}
                        }}
                      }
                      },
         "tags": {"type": "keyword"},
          "tag_positions": {
                      "properties": {
                        "tag": {"type": "keyword"},
                        "tag_start": {"type": "long"},
                        "tag_end": {"type": "long"}}},
      "source": {
      "properties": {
        "title" : {"type": "text"},
        "description": {"type": "text"},
        "media_type": {"type": "text"},
        "url": {"type": "text"}
      }
    },
       "moderation": {
      "properties": {
        "done": {"type":"boolean"}
      }
    }
   }
  }
 }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...