Elasticsearch查询匹配数组

问题描述

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" } }
          ]
        }
      }
    }
  }
}

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...