Как создать индекс из нескольких элементов json массива

Добрый день!
Создаю индекс отправляя, каждый элемент json массива отдельно:

curl -X POST 'localhost:9200/ps-products-ru-ru/product' -H 'Content-Type: application/json' -d'
{ "id_supplier": "0", 
"id_manufacturer": "0", 
"id_category_default": "3673", 
"id_shop_default": "1",
"id_tax_rules_group": "1",
"on_sale": "0",
"online_only": "0", 
"ean13": "351340", 
"isbn": "", 
"upc": "", 
"ecotax": "0.000000", 
"quantity": "9", 
"minimal_quantity": "0", 
"low_stock_threshold": null, 
"low_stock_alert": "0", 
"price": "0.000000", 
"wholesale_price": "0.000000", 
"unity": "", 
"unit_price_ratio": "0.000000", 
"additional_shipping_cost": "0.00", 
"reference": "", 
"supplier_reference": "1", 
"location": "", 
"width": "0.000000",
"height": "0.000000", 
"depth": "0.000000", 
"weight": "0.000000", 
"out_of_stock": "0", 
"additional_delivery_times": "1", 
"quantity_discount": "0", 
"customizable": "0", 
"uploadable_files": "0", 
"text_fields": "0", 
"active": true, 
"redirect_type": "", 
"id_type_redirected": "0", 
"available_for_order": "1", 
"available_date": "0000-00-00", 
"show_condition": "0", 
"condition": "new", 
"show_price": "0", 
"indexed": "1", 
"visibility": "both", 
"cache_is_pack": "0", 
"cache_has_attachments": "0", 
"is_virtual": "0", 
"cache_default_attribute": "0", 
"date_add": "2018-10-29 15:18:49", 
"date_upd": "2018-10-29 15:18:49", 
"advanced_stock_management": "0", 
"pack_stock_type": "3", 
"state": "1", 
"yandexmarketxml": "1", 
"id_shop": "1", 
"id_lang": "1", 
"description": "", 
"link_rewrite": "kabely_spoevn_4h0_5", 
"name": "\u0421\u041f\u041e\u042d\u0412\u041d 4\u04450,5", 
"available_now": "", 
"available_later": "", 
"delivery_in_stock": "", 
"delivery_out_stock": "", 
"position": "0", 
"category_name": "\u041a\u0430\u0431\u0435\u043b\u044c \u0421\u041f\u041e\u042d\u0412\u041d", 
"category_link_rewrite": "kabely_spoevn", 
"manufacturer_name": null, 
"tags_list": [], 
"attributes_list": [], 
"features_list": [] 
}'

Так создается, для одного товара.
Если хочу отправить на индексацию сразу несколько элементов, выдают ошибки Unexpected неожиданные символы , и [ если отправляю несколько товаров в таком формате json:

{
"body": [
	{ 
		"id_supplier": "0", 
		"id_manufacturer": "0", 
		"id_category_default": "3673", 
		"id_shop_default": "1",
		"id_tax_rules_group": "1",
		"on_sale": "0",
		"online_only": "0", 
		"ean13": "351340", 
		"isbn": "", 
		"upc": "", 
		"ecotax": "0.000000", 
		"quantity": "9", 
		 ...
		"manufacturer_name": null, 
		"tags_list": [], 
		"attributes_list": [], 
		"features_list": [] 
	},
	{ 
		"id_supplier": "0", 
		"id_manufacturer": "0", 
		"id_category_default": "3673", 
		"id_shop_default": "1",
		"id_tax_rules_group": "1",
		"on_sale": "0",
		"online_only": "0", 
		"ean13": "351340", 
		"isbn": "", 
		"upc": "", 
		"ecotax": "0.000000", 
		"quantity": "9", 
		 ...
		"manufacturer_name": null, 
		"tags_list": [], 
		"attributes_list": [], 
		"features_list": [] 
	}
]
}

Как отправить в индекс elastic search большое кол-во элементов разом?

Думаю, Вам нужен Bulk API:
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.