zoukankan      html  css  js  c++  java
  • 搜索评分机制--negative boost(想搜索的展示在前面,不想搜索的展示在后面)

    3、negative boost

    搜索包含java,不包含spark的doc,但是这样子很死板
    搜索包含java,尽量不包含spark的doc,如果包含了spark,不会说排除掉这个doc,而是说将这个doc的分数降低
    包含了negative term的doc,分数乘以negative boost,分数降低

    GET /forum/article/_search 
    {
      "query": {
        "boosting": {
          "positive": {
            "match": {
              "content": "java"
            }
          },
          "negative": {
            "match": {
              "content": "spark"
            }
          },
          "negative_boost": 0.2
        }
      }
    }
    negative的doc,会乘以negative_boost,降低分数
    POST /blogs/_bulk
    { "index": { "_id": 1 }}
    {"title":"Apple iPad", "content":"Apple iPad,Apple iPad" }
    { "index": { "_id": 2 }}
    {"title":"Apple iPad,Apple iPad", "content":"Apple iPad" }
    
    
    POST blogs/_search
    {
      "query": {
        "bool": {
          "should": [
            {"match": {
              "title": {
                "query": "apple,ipad",
                "boost": 1.1
              }
            }},
    
            {"match": {
              "content": {
                "query": "apple,ipad",
                "boost":
              }
            }}
          ]
        }
      }
    }
    
    
    
    
    
    
    
    
    
    POST /news/_bulk
    { "index": { "_id": 1 }}
    { "content":"Apple Mac" }
    { "index": { "_id": 2 }}
    { "content":"Apple iPad" }
    { "index": { "_id": 3 }}
    { "content":"Apple employee like Apple Pie and Apple Juice" }
    
    
    POST news/_search
    {
      "query": {
        "bool": {
          "must": {
            "match":{"content":"apple"}
          }
        }
      }
    }
    
    POST news/_search
    {
      "query": {
        "bool": {
          "must": {
            "match":{"content":"apple"}
          },
          "must_not": {
            "match":{"content":"pie"}
          }
        }
      }
    }
    
    POST news/_search
    {
      "query": {
        "boosting": {
          "positive": {
            "match": {
              "content": "apple"
            }
          },
          "negative": {
            "match": {
              "content": "pie"
            }
          },
          "negative_boost": 0.5
        }
      }
    }
  • 相关阅读:
    微信小程序之项目的创建
    Java中的线程--多线程面试题
    Java中的线程--并发库中的集合
    Java中的线程--线程中的工具
    Java中的线程--Lock和Condition实现线程同步通信
    Linux指定用户运行程序
    CPU、内存、磁盘三者的关系
    shell从字符串中提取子串(正则表达式)
    ssh登录失败的常见问题分析
    正则表达式匹配不含有某字符串的行
  • 原文地址:https://www.cnblogs.com/wangchuanfu/p/14149946.html
Copyright © 2011-2022 走看看