Jak utworzyć indeks ElasticSearch w postaci curl

0

Pytanie

Mam następujące zapytanie do tworzenia indeksu:

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

Otrzymuję następujący błąd:

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

Myślę, że mój składnia do tworzenia indeksu jest prawidłowy. Wdzięczny za wszelkie informacje. Dziękuję

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

Najlepsza odpowiedź

1

Po prostu usuń athlete ponieważ więcej nie potrzeba żadnej nazwy typu mapowania, reszta jest w porzą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

Dziękuję. To plus fakt, że zmieniłem pasek na tekst. Dziękuję
Timothy Clotworthy

Super, cieszę się, że to pomogło!
Val

W innych językach

Ta strona jest w innych językach

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