ElasticSearch - Не удалось проанализировать содержимое на карте - Неожиданный символ ('\ "' - PullRequest
0 голосов
/ 24 января 2019

Хотите знать, если вы можете помочь, у меня проблемы с моим кодом в Elasticsearch, который выдает ошибку.Мой код ниже, и вывод также ниже, любая помощь очень ценится.

curl -X PUT "localhost:9200/_mapping/jdbc" -H 'Content-Type: application/x-ndjson' -d '
{
"mappings": {
"jdbc" : { 
"properties" : {
"mac_client" : {
"type" : "string",
"index": "not_analyzed"
}
"mac_sniffer" : {
"type" : "string"
"index": "not_analyzed"
}
"rssi" : {
"type" : "long"
}
"timestamp" : {
"type" : "date"
"format" : "strict_date_optional_time||epoch_millis"
}
}
}
}
}
'

Ошибка, которую я получаю

    {"error":{"root_cause":[{"type":"parse_exception","reason":"Failed to parse content to map"}],"type":"parse_exception","reason":"Failed to parse content to map","caused_by":{"type":"json_parse_exception","reason":"Unexpected character ('\"' (code 34)): was expecting comma to separate OBJECT entries\n at [Source: org.elasticsearch.common.compress.deflate.DeflateCompressor$1@66d3b7cb; line: 10, column: 12]"}},"status":400}

Ответы [ 2 ]

0 голосов
/ 24 января 2019

Ваш json недействителен, вы можете использовать что-то вроде https://jsonformatter.curiousconcept.com/ для проверки в будущем.

Следующее должно быть в силе - хорошо отформатированный json всегда помогает увидеть ошибки

{
  "mappings": {
    "jdbc": {
      "properties": {
        "mac_client": {
          "type": "string",
          "index": "not_analyzed"
        },
        "mac_sniffer": {
          "type": "string",
          "index": "not_analyzed"
        },
        "rssi": {
          "type": "long"
        },
        "timestamp": {
          "type": "date",
          "format": "strict_date_optional_time||epoch_millis"
        }
      }
    }
  }
}
0 голосов
/ 24 января 2019

В вашем объекте JSON отсутствуют запятые.

curl -X PUT "localhost:9200/_mapping/jdbc" -H 'Content-Type: application/x-ndjson' -d '
{
"mappings": {
"jdbc" : { 
"properties" : {
"mac_client" : {
"type" : "string",
"index": "not_analyzed"
}, // <==== comma missing
"mac_sniffer" : {
"type" : "string"
"index": "not_analyzed"
}, // <==== comma missing
"rssi" : {
"type" : "long"
}, // <==== comma missing
"timestamp" : {
"type" : "date"
"format" : "strict_date_optional_time||epoch_millis"
}
}
}
}
}
'
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...