Comment créer un Index ElasticSearch comme curl

0

La question

J'ai la requête suivante pour créer un index:

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"
          }
        }
     }
   }
}'

J'obtiens l'erreur suivante:

{
  "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
}

Je pense que ma syntaxe pour la création de l'index est incorrect. Reconnaissant pour toutes les idées. Merci

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

La meilleure réponse

1

Retirez simplement athlete comme il n'y a pas besoin de tout type de mappage de nom de plus, le reste est très bien:

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

Merci. Qu'en plus j'ai changé de chaîne de texte. merci
Timothy Clotworthy

Cool, content que ça a aidé!
Val

Dans d'autres langues

Cette page est dans d'autres langues

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