es

es 搜索

{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "grade": "00cr12"
          }
        },
        {
          "nested": {
            "path": "attrs",
            "query": {
              "bool": {
                "must": [
                  {
                    "match": {
                      "attrs.name": "c"
                    }
                  },
                  {
                    "match": {
                      "attrs.maxv": "18"
                    }
                  },
                  {
                    "match": {
                      "attrs.attrId": "10"
                    }
                  }
                ]
              }
            }
          }
        },
        {
          "nested": {
            "path": "attrs",
            "query": {
              "bool": {
                "must": [
                  {
                    "match": {
                      "attrs.name": "p"
                    }
                  },
                  {
                    "match": {
                      "attrs.maxv": "28"
                    }
                  },
                  {
                    "match": {
                      "attrs.attrId": "11"
                    }
                  }
                ]
              }
            }
          }
        }
      ]
    }
  }
}

 查看  http://192.168.0.166:9200/test/col/_mapping?pretty

先新建一个,在创建之前修改类型
curl -XPOST "http://192.168.0.166:9200/test/col/_mapping?pretty" -d '{
"col": {
"properties": {
"attributeCategoryId": {
"type" : "string"
}
}
}
}'

 

 

在list attrs后添加 "type": "nested",这样就可以搜索list里面单独的对象的内容了

curl -XPOST "http://192.168.0.166:9200/matmass_test/col/_mapping?pretty" -d '{
     "col" : {
        "properties" : {
          "attrs" : {
            "type": "nested",
            "properties" : {
              "attrId" : {
                "type" : "long"
              },
              "maxv" : {
                "type" : "long"
              },
              "minv" : {
                "type" : "long"
              },
              "name" : {
                "type" : "string"
              },
              "tmplate" : {
                "type" : "long"
              }
            }
          },
          "grade" : {
            "type" : "string"
          }
        }
      }
}'

 配置最大读取数

curl -XPUT http://192.168.0.166:9200/索引名/_settings -d '{ "index" : { "max_result_window" : 100000000}}'

 

参考

java api 动态条件拼接  http://blog.youkuaiyun.com/sampson_lee/article/details/46771165

转载于:https://www.cnblogs.com/yaoyao66123/p/8205564.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值