es7 10-10 java搜索接入

低价排序模型
只影响召回 不影响排序 使用replace 

# 低价排序
GET shop/_search
{
  "_source": "*",
  "script_fields": {
    "distance": {
      "script": {
        "source": "haversin(lat,lon,doc['location'].lat,doc['location'].lon)",
        "lang":"expression",
        "params": {"lat":31.23916171,"lon":121.48780049}
      }
    }
  },
  "query": {
    "function_score": {
      "query": {
        "bool": {
          "must": [
            {
              "match": {
                "name": {"query": "凯悦","boost": 0.1}
              }
            },{
              "term": 
               { "seller_disabled_flag": 0} // 表明商家没有被禁用
              },{
                "term": {
                  "category_id": {
                    "value": "2"
                  }
                }
              }
          ]
        }
      },
      "functions": [ // 定义排序规则
        {
          "field_value_factor": { // 商家的评分以5分为归一化
            "field": "price_per_man"
          },
          "weight": 1
        }
      ],
      "score_mode": "sum",
      "boost_mode": "replace"  // 和对应的query 的打分规则  sum改为replace 文本相关性不考虑 基于距离和评分
    }
  }
  , "sort": [
    {
      "_score": {
        "order": "desc"
      }
    }
  ]
}

标签 “落地窗” 无法查询

GET shop/_search
{
  "_source": "*",
  "script_fields": {
    "distance": {
      "script": {
        "source": "haversin(lat,lon,doc['location'].lat,doc['location'].lon)",
        "lang":"expression",
        "params": {"lat":31.23916171,"lon":121.48780049}
      }
    }
  },
  "query": {
    "function_score": {
      "query": {
        "bool": {
          "must": [
            {
              "match": {
                "name": {"query": "凯悦","boost": 0.1}
              }
            },{
              "term": 
               { "seller_disabled_flag": 0} // 表明商家没有被禁用
              },{
                "term": {
                  "tags": {
                    "value": "落地大窗"
                  }
                }
              }
          ]
        }
      },
      "functions": [ // 定义排序规则
        {
          "gauss": { // 高斯衰减函数打分
            "location": {
              "origin": "31.23916171,121.48780049",
              "scale": "100km",
              "offset": "0km", // 起始点
               "decay": 0.5
            }
          },
          "weight": 9 // 相对于评分 距离是主要因素
        },{
          "field_value_factor": {
            "field": "remark_score" // 评分
          },
          "weight": 0.2
        }
        ,{
          "field_value_factor": { // 商家的评分以5分为归一化
            "field": "seller_remark_score"
          },
          "weight": 0.1
        }
      ],
      "score_mode": "sum",
      "boost_mode": "replace"  // 和对应的query 的打分规则  sum改为replace 文本相关性不考虑 基于距离和评分
    }
  }
  , "sort": [
    {
      "_score": {
        "order": "desc"
      }
    }
  ],
  "aggs": {
    "group_by_tags": {
      "terms": {
        "field": "tags"
      }
    }
  }
}

 

tags 带fielddata 是可以被aggrate的 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值