Elasticsearch(三) 查询与过滤

本文探讨如何在Elasticsearch中实现查询与过滤,特别是针对子文档的object字段如spu_info.spu_name和brand_info.brand_name的匹配,同时过滤is_hidden和state字段。通过multi_match查询和cross_fields策略,结合inner_hits展示子文档源信息,以及使用bool过滤器进行精细化筛选。
摘要由CSDN通过智能技术生成

这里使用的场景是在子文档中匹配object字段spu_info.spu_name,brand_info.brand_name,过滤子文档的is_hidden和state的字段,并且在父文档也过滤is_hidden和state字段。

search_obj = {
          "query": {
            "filtered": {
              "query":{
                  "has_child":{
                  "type":"skus",
                  "score_mode":"max",
                  "query":{
                    "filtered":{
                       "query": {
                          "multi_match": {
                            "query": "全纺家私双人床",
                            "type": "cross_fields",
                            "fields": [
                              "spu_info.spu_name^3",
                              "brand_info.brand_name",
                              "tags"
                            ]
                          }
     
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值