Jak vytvořit ElasticSearch Index jako curl

0

Otázka

Mám následující dotaz, chcete-li vytvořit 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á jsem dostat následující chybu:

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

Myslím, že můj syntaxe pro vytvoření indexu je nesprávné. Vděčný za jakékoliv postřehy. Děkuji

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

Nejlepší odpověď

1

Jednoduše odstranit athlete jak tam je žádná potřeba pro jakýkoliv typ mapování jméno už, zbytek je v pořádku:

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

Díky. To plus jsem změnil řetězec textu. díky
Timothy Clotworthy

Super, jsem rád, že to pomohlo!
Val

V jiných jazycích

Tato stránka je v jiných jazycích

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