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

  • 相关阅读:
    hadoop-2.6.0-src源码导入Eclipse 转载
    sqoop1.4.6+hadoop2.6.0 转载
    eclipse构建maven+scala+spark工程 转载
    eclipse连hadoop2.x运行wordcount 转载
    Thinking in BigData 系列
    hadoop 安装教程 转载
    JAVA泛型详解2 转载
    Java泛型详解 转载
    HttpClient 版本变化 转载
    HttpClient 与 HtmlParser 简介 转载
  • 原文地址:https://www.cnblogs.com/qiu-hua/p/14196940.html
Copyright © 2011-2022 走看看