es7 10-4 门店搜索4

# 使用function score解决排序模型
# tf-idf 打分和function score 做融合
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} // 表明商家没有被禁用
              }
          ]
        }
      },
      "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": "sum" // 和对应的query 的打分规则  改为 文本相关性不考虑 基于距离和评分
    }
  }
  , "sort": [
    {
      "_score": {
        "order": "desc"
      }
    }
  ]
}

处理了距离字段
处理了召回规则

衰减函数分为如下三类: 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值