zoukankan      html  css  js  c++  java
  • elasticsearch 基于文章点赞数计算评分

    POST news_index/_bulk
    {"index":{"_id":1}}
    {"title":"ElasticSearch原理- 神一样的存在"}
    {"index":{"_id":2}}
    {"title":"Elasticsearch 快速开始","like":5}
    {"index":{"_id":3}}
    {"title":"开源搜索与分析· Elasticsearch","like":10}
    {"index":{"_id":4}}
    {"title":"铭毅天下 死磕Elasticsearch", "like":1000}
    
    
    
    GET news_index/_search
    {
      "query": {
        "function_score": {
          "query": {
            "match": {
              "title": "Elasticsearch"
            }
          },
          "field_value_factor": {
            "field": "like",
            "modifier": "log1p",
            "factor": 0.1,
            "missing": 1
          },
          "boost_mode": "sum"
        }
      }
    }

      • 评分计算公式解读:new_score = old_score + log(1 + 0.1 * like值)
      • missing含义:使用 field_value_factor 时要注意,有的文档可能会缺少这个字段,加上 missing 来个这些缺失字段的文档一个缺省值
  • 相关阅读:
    利用序列化进行深度克隆
    原型链
    本地储存cookie,localStorage,sessionStorage
    ES6创建类
    hexo基本命令
    mouseent和mouseover的区别
    Event
    offset,client,scroll
    字符串的常用方法
    数组去重
  • 原文地址:https://www.cnblogs.com/wangchuanfu/p/14217673.html
Copyright © 2011-2022 走看看