问题描述
id: 1,name: "Jean Pantalon",title: null,subtitle: null,description: null,tags: null,SEOUrl: null,clickCounter: 0,model: null,sku: null,ean: null,displayPrice: 0,price: 0,isActive: true,isDeleted: false,productPhotos: null,productCategories: [
{
id: 1,productId: 1,categoryId: 2,category: {
id: 2,name: "Spor",topCategoryId: 0,subCategories: null
}
},]
大家好,elasticseaarch具有这样的json产量,我想对其进行过滤,例如product类别te类别体育类中的名称,我该如何编写此查询
我正在使用c#ta嵌套库
解决方法
我不知道如何在您的lib中执行此操作,而是在elasticsearch中:
productCategories必须使用“嵌套”数据类型进行映射。 然后,您将可以构建如下查询:
GET /my-index/_search
{
"query": {
"nested": {
"path": "productCategories","query": {
"bool": {
"must": [
{ "match": { "productCategories.category.name": "sport" } }
]
}
}
}
}
}