在弹性搜索7.11.0
中,我有描述的产品。
{
"_index" : "products",
"_type" : "_doc",
"_id" : "1234567890123",
"_source" : {
"ean" : "1234567890123",
"title" : "Very nice product",
"merchants" : [
{
"id" : 2,
"name" : "example.com",
"product_id" : "22561",
"description" : "Description of the product",
"price" : "4.25",
"url" : "https://example.com/product",
"imageUrl" : "https://example.com/images/product.jpg",
"in_stock" : true
}
]
}
}
我已经通过批量index
操作添加了这个产品。如果存在,它将更新它,如果不存在,它将创建它。
我收到来自多个商家的产品。一种产品可以存在于一个或多个商家中。这就是为什么我有嵌套元素merchants
。
作为操作想要做的事情bulk
如下:
导入运行:
- 产品不存在:
Create a new product with a nested merchant
- 产品存在:
Check if the merchant exists. If not, create a new nested element, otherwise update the nested elements
我可以一个一个地做,但是由于产品的数量,它不是很方便。我正在使用elasticsearch PHP package
.