Como criar um ElasticSearch Índice de curl

0

Pergunta

Eu tenho a consulta a seguir para criar um índice:

curl -X PUT "http://localhost:9200/my-index-000002?pretty" -H 'Content-Type: application/json' -d'
{
   "mappings": {
      "athlete": {
         "properties": {
          "birthdate": {
           "type": "date",
           "format": "dateOptionalTime"
           },
           "location": {
               "type": "geo_point"
            },
            "name": {
               "type": "string"
            },
            "rating": {
             "type": "integer"
          },
          "sport": {
             "type": "string"
          }
        }
     }
   }
}'

Estou recebendo o seguinte erro:

{
  "error": {
   "root_cause": [
   {
     "type": "mapper_parsing_exception",
     "reason": "Root mapping definition has unsupported parameters:  [athlete : {properties={birthdate={format=dateOptionalTime, type=date}, name={type=string}, rating={type=integer}, location={type=geo_point}, sport={type=string}}}]"
   }
  ],
  "type": "mapper_parsing_exception",
  "reason": "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:  [athlete : {properties={birthdate={format=dateOptionalTime, type=date}, name={type=string}, rating={type=integer}, location={type=geo_point}, sport= {type=string}}}]",
  "caused_by": {
  "type": "mapper_parsing_exception",
  "reason": "Root mapping definition has unsupported parameters:  [athlete : {properties={birthdate={format=dateOptionalTime, type=date}, name={type=string}, rating={type=integer}, location={type=geo_point}, sport={type=string}}}]"
}
},
"status": 400
}

Eu acho que a minha sintaxe para criar o índice é incorreto. Grato por qualquer insights. Obrigado

elasticsearch
2021-11-22 17:33:06
1

Melhor resposta

1

Basta remover athlete como não há nenhuma necessidade para qualquer tipo de mapeamento de nome de mais, o resto é bom:

curl -X PUT "http://localhost:9200/my-index-000002?pretty" -H 'Content-Type: application/json' -d'
{
   "mappings": {                     
                                      <---- remove this line
         "properties": {
          "birthdate": {
           "type": "date",
           "format": "dateOptionalTime"
           },
           "location": {
               "type": "geo_point"
            },
            "name": {
               "type": "string"
            },
            "rating": {
             "type": "integer"
          },
          "sport": {
             "type": "string"
          }
        }
   }
}'
2021-11-22 17:34:48

Obrigado. Que mais eu mudei de seqüência de caracteres de texto. obrigado
Timothy Clotworthy

Legal, que bom que ajudou!
Val

Em outros idiomas

Esta página está em outros idiomas

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................