简体   繁体   English

弹性搜索:词条查询的负提升

[英]Elastic search: negative boost for term query

At the moment I'm using queries like the following with positive boosting of a term.目前,我正在使用如下查询对一个词进行积极提升。

    "query": {
        "bool" : {
            "must" : {
                "term" : { "title" : {value :"word", boost: 2.0}}
            }
         }
      }

This type of query is described here . 此处描述此类查询。 I would like to know if it is possible to use negative boosting of term just like the above, but instead of 2.0 a -2.0.我想知道是否可以像上面那样使用术语的负提升,而不是 2.0 a -2.0。 So like this:所以像这样:

     "query": {
        "bool" : {
            "must" : {
                "term" : { "title" : {value :"word", boost: -2.0}}
            }
         }
      }

I couldn't find any documentation on it.我找不到任何关于它的文档。 It only tells the default value for boost is 1.0.它只告诉 boost 的默认值是 1.0。 And all examples use positive boosting.并且所有示例都使用正提升。 There is however some kind of negative boost ( described here ), but that is boosting queries instead of terms.然而,存在某种负面提升(描述here ),但这是提升查询而不是术语。

The best way is to try it out ;-) If you'd get a search exception or something you'll know negative boosts are not allowed.最好的方法是尝试一下 ;-) 如果您遇到搜索异常或您会知道不允许出现负面提升的情况。 But if you try you'll see that it's not the case and negative boosts are perfectly valid and impact the scores.但是,如果您尝试,您会发现情况并非如此,负提升是完全有效的,并且会影响分数。

As you saw, you can also use boosting_query with a negative_boost which will demote results that match a given query (eg those documents having "title": "word" ).如您所见,您还可以将boosting_querynegative_boost一起使用,这将降低与给定查询匹配的结果(例如,那些具有"title": "word"文档)。 Watch out, though, than when using this query the negative_boost value must be a "positive" number as it will already be negated within the source code.但是要注意,当使用这个查询时, negative_boost值必须是一个“正”数,因为它已经在源代码中被否定了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM