2015-04-05 5 views
9

Ich versuche Import bulk eine POST-Anforderung an localhost:9200/products/product/_bulk mit folgendem JSON mit:Elasticsearch Bulk-API - Unerwarteter End-of-Eingang: erwartet der Nähe Marker für ARRAY

[ 
    { "index": {"_index": "products", "_type": "product", "_id": 1} }, 
    { "title": "Product A","description": "Brand A - Product A - 1.5 kg","price": 3.49,"sku": "wi208564","supermarket": "AJ","categories": "Fruit AJ","product_type": "Sinaasappels - mandarijnen","brand": "Brand A\n"}, 
    { "index": {"_index": "products", "_type": "product", "_id": 2} }, 
    { "title": "Product B","description": "Brand B - Product B - 1 kg","price": 2.49,"sku": "wi308564","supermarket": "AJ","categories": "Fruit AJ","product_type": "Sinaasappels - mandarijnen","brand": "Brand B\n"}, 
    { "index": {"_index": "products", "_type": "product", "_id": 3} }, 
    { "title": "Product C","description": "Brand C - Product C - 2.5 kg","price": 4.49,"sku": "wi108564","supermarket": "AJ","categories": "Fruit AJ","product_type": "Sinaasappels - mandarijnen","brand": "Brand C\n"} 
] 

Ich halte die folgende Fehlermeldung erhalten :

{ 
"error": "JsonParseException[Unexpected end-of-input: expected close marker for ARRAY (from [Source: [[email protected]; line: 1, column: 0])\ at [Source: [[email protected]; line: 1, column: 3]]", 
"status": 500 
} 

Ich habe versucht, das JSON-Format zu ändern, aber es hat nicht geholfen. Was scheint falsch zu laufen?

Antwort

16

Ihre Formatierung ist nicht ganz richtig: für Massenanforderung werden einzelne Elemente durch Zeilenumbruchzeichen (keine Kommas) getrennt und es gibt keine eckigen Klammern am Ende (dh die Nutzlast ist eine Folge von JSON-Dokumenten, aber das Ganze Nutzlast ist nicht selbst ein gültiges Dokument json)

Ihre Daten aussehen sollte

{ "index": {"_index": "products", "_type": "product", "_id": 1} } 
{ "title": "Product A","description": "Brand A - Product A - 1.5 kg","price": 3.49,"sku": "wi208564","supermarket": "AJ","categories": "Fruit AJ","product_type": "Sinaasappels - mandarijnen","brand": "Brand A\n"} 
{ "index": {"_index": "products", "_type": "product", "_id": 2} } 
{ "title": "Product B","description": "Brand B - Product B - 1 kg","price": 2.49,"sku": "wi308564","supermarket": "AJ","categories": "Fruit AJ","product_type": "Sinaasappels - mandarijnen","brand": "Brand B\n"} 
+0

newline am Ende des json erforderlich ist –

Verwandte Themen