Elasticsearch Nest 获取和更新单个文档
Elasticsearch Nest Getting and updating a single Document
我希望能够select单个文档这里是文档外观的示例
{
"_index": "myindex_products",
"_type": "product",
"_id": "8Wct9mEBlkDZwzEMRfbG",
"_version": 1,
"_score": 1,
"_source": {
"productId": 5749,
"name": "Product Name Here",
"productCode": "PRODCODE",
"productCategoryId": 73,
"length": 6,
"height": 0,
"productTypeId": 1,
"url": "product-name-here",
"productBrandId": 7,
"width": 0,
"dispatchTimeInDays": 10,
"leadTimeInDays": 6,
"stockAvailable": 0,
"weightKg": 0.001,
"reviewRating": 5,
"reviewRatingCount": 17,
"limitedStock": false,
"price": 16.3,
"productImage": "28796-14654.jpg",
"productCategory": {
"productCategoryId": 73,
"name": "Accessories - New",
"fullPath": "Accessories - New",
"code": "00057"
},
"productSpecification": [
{
"productSpecificationId": 127151,
"productId": 5749,
"specificationId": 232,
"name": "Brand",
"value": "Brand1"
}
,
{
"productSpecificationId": 127175,
"productId": 5749,
"specificationId": 10,
"name": "Guarantee",
"value": "10 years"
}
]
}
}
_id 是在我编制索引时生成的,所以我在要更新时不知道这一点。我有 productId 值,我想将其用于 select 一个文档,然后 update/delete 如果您知道特定的确切值,是否有办法 return 单个文档。
谢谢
在编制索引时,您可以使用类似 PUT your_index/5749
的内容(5749 是您的产品 ID),ES 会将其值用于 _id 字段而不是 auto-generating。
我希望能够select单个文档这里是文档外观的示例
{
"_index": "myindex_products",
"_type": "product",
"_id": "8Wct9mEBlkDZwzEMRfbG",
"_version": 1,
"_score": 1,
"_source": {
"productId": 5749,
"name": "Product Name Here",
"productCode": "PRODCODE",
"productCategoryId": 73,
"length": 6,
"height": 0,
"productTypeId": 1,
"url": "product-name-here",
"productBrandId": 7,
"width": 0,
"dispatchTimeInDays": 10,
"leadTimeInDays": 6,
"stockAvailable": 0,
"weightKg": 0.001,
"reviewRating": 5,
"reviewRatingCount": 17,
"limitedStock": false,
"price": 16.3,
"productImage": "28796-14654.jpg",
"productCategory": {
"productCategoryId": 73,
"name": "Accessories - New",
"fullPath": "Accessories - New",
"code": "00057"
},
"productSpecification": [
{
"productSpecificationId": 127151,
"productId": 5749,
"specificationId": 232,
"name": "Brand",
"value": "Brand1"
}
,
{
"productSpecificationId": 127175,
"productId": 5749,
"specificationId": 10,
"name": "Guarantee",
"value": "10 years"
}
]
}
}
_id 是在我编制索引时生成的,所以我在要更新时不知道这一点。我有 productId 值,我想将其用于 select 一个文档,然后 update/delete 如果您知道特定的确切值,是否有办法 return 单个文档。
谢谢
在编制索引时,您可以使用类似 PUT your_index/5749
的内容(5749 是您的产品 ID),ES 会将其值用于 _id 字段而不是 auto-generating。