温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

elasticsearch 排序 算法

发布时间:2020-06-17 22:25:12 来源:网络 阅读:878 作者:大海之中 栏目:开发技术

如何将tfidf映射到[1,3] 区间内


(1)建立映射x→arctanx,此为一一映射,把全体实数R映射到开区间(-π/2,π/2)
(2)开区间(-π/2,π/2)到开区间(0,1)只需要一个线性映射就可以,设为f(x)=ax+b,则有f(-π/2)=1且f(π/2)=3,解得a=2/π,b=2
综合一下,映射x→2(arctanx)/π+2,即把全体实数映射到(1,3)



所以表达式可以写成


 "script_score" : {

          "script" : "return atan(_score.doubleValue())*2/3.14159+2"

        }



为了只使用函数值 设置 "boost_mode": "replace",


所以整个请求如下


curl -XGET 'http://localhost:9200/*/*/_search?pretty&explain' -d '{

 "size" : 1,

  "query" : {

    "function_score" : {

      "query" : {

            "bool" : {

               "should" : [ {

                "match" : {

                  "_all" : {

                    "query" : "关键字",

                    "type" : "boolean",

                    "operator" : "AND",

    "boost": 10

                  }

                }

              }, {

                "match" : {

                  "company_name" : {

                    "query" : "关键字",

                    "type" : "boolean",

                    "operator" : "AND",

"boost": 10

                  }

                }

              } ],

              "minimum_should_match" : "1"

            }

      },

      "functions" : [

          {

        "script_score" : {

          "script" : "return atan(_score.doubleValue())*2/3.14159+2"

        }

      },{

          "filter" : {

          "match" : {

            "company_name" : {

              "query" : "关键字",

              "type" : "boolean",

              "operator" : "AND"

            }

          }

        },

        "weight" : 2

      }


 ],

      "score_mode" : "sum",

 "boost_mode": "replace"

    }

  },

  "aggregations" : {

    "agg" : {

      "terms" : {

        "field" : "member_id",

        "size" : 0,

        "order" : {

          "top_hit" : "desc"

        }

      },

      "aggregations" : {

        "top_hit" : {

          "max" : {

            "script" : {

              "inline" : "_score"

            }

          }

        }

      }

    }

  }

  }'


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI