zoukankan      html  css  js  c++  java
  • ES基础(二十五)综合排序:Function Score Query 优化算分

     

     

     

     

     

     

     

    课程Demo

    DELETE blogs
    PUT /blogs/_doc/1
    {
      "title":   "About popularity",
      "content": "In this post we will talk about...",
      "votes":   0
    }
    
    PUT /blogs/_doc/2
    {
      "title":   "About popularity",
      "content": "In this post we will talk about...",
      "votes":   100
    }
    
    PUT /blogs/_doc/3
    {
      "title":   "About popularity",
      "content": "In this post we will talk about...",
      "votes":   1000000
    }
    
    
    POST /blogs/_search
    {
      "query": {
        "function_score": {
          "query": {
            "multi_match": {
              "query":    "popularity",
              "fields": [ "title", "content" ]
            }
          },
          "field_value_factor": {
            "field": "votes"
          }
        }
      }
    }
    
    POST /blogs/_search
    {
      "query": {
        "function_score": {
          "query": {
            "multi_match": {
              "query":    "popularity",
              "fields": [ "title", "content" ]
            }
          },
          "field_value_factor": {
            "field": "votes",
            "modifier": "log1p"
          }
        }
      }
    }
    
    
    POST /blogs/_search
    {
      "query": {
        "function_score": {
          "query": {
            "multi_match": {
              "query":    "popularity",
              "fields": [ "title", "content" ]
            }
          },
          "field_value_factor": {
            "field": "votes",
            "modifier": "log1p" ,
            "factor": 0.1
          }
        }
      }
    }
    
    
    POST /blogs/_search
    {
      "query": {
        "function_score": {
          "query": {
            "multi_match": {
              "query":    "popularity",
              "fields": [ "title", "content" ]
            }
          },
          "field_value_factor": {
            "field": "votes",
            "modifier": "log1p" ,
            "factor": 0.1
          },
          "boost_mode": "sum",
          "max_boost": 3
        }
      }
    }
    
    POST /blogs/_search
    {
      "query": {
        "function_score": {
          "random_score": {
            "seed": 911119
          }
        }
      }
    }

    本文来自博客园,作者:秋华,转载请注明原文链接:https://www.cnblogs.com/qiu-hua/p/14196940.html

  • 相关阅读:
    MySQL 批量删除相同前缀的表
    MySQL 命令登录
    MySQL 密码修改
    谷歌浏览器开发者工具截图
    VIM命令图解
    基于环境变量为多用户配置不同的JDK(win)
    Reddit: 只有独生子女才明白的事
    JSONObject与null
    SpringFramework中重定向
    XML修改节点值
  • 原文地址:https://www.cnblogs.com/qiu-hua/p/14196940.html
Copyright © 2011-2022 走看看