zoukankan      html  css  js  c++  java
  • elasticsearh 自定义排序( 帖子点赞数目越高拍的越靠前)

    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
          }
        }
      }
    }
     
  • 相关阅读:
    区域赛系列一多边形划分(卡特兰数)
    Going Home(最大匹配km算法)
    奔小康赚大钱(km)
    Air Raid(最小路径覆盖)
    Save Princess(丑数)
    Asteroids(最小点覆盖)
    Windows命令行命令总结
    SPI协议详解
    Python实现串口通信(pyserial)
    python中进制转换
  • 原文地址:https://www.cnblogs.com/wangchuanfu/p/14149660.html
Copyright © 2011-2022 走看看