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
        }
      }
    }
  • 相关阅读:
    用javascript进行拖拽3(转)
    用javascript进行拖拽4(转)
    设计模式:设计自己的MVC框架(转)
    用javascript进行拖拽1(转)
    .NET Framework
    微软软件开发技术二十年回顾
    .NET Framework是什么
    .net中语音识别和语音合成入门篇
    用javascript进行拖拽5(转)
    .net3.0
  • 原文地址:https://www.cnblogs.com/wangchuanfu/p/14149946.html
Copyright © 2011-2022 走看看