如何为elasticsearch中的单个字段分配常量增值?

时间:2013-08-23 13:07:10

标签: java elasticsearch

在弹性搜索中有很多评分/提升选项,但我没有发现为特定领域添加恒定提升值的可能性。如果存在这样的选项,映射应该如何?也许有一个选项来计算整个文档的分数,具体取决于哪个字段被击中?

1 个答案:

答案 0 :(得分:2)

以下是解决方案:包装器查询“custom_boost_factor”,它将每种类型的嵌入式查询的得分相乘:

curl -XPOST 'http://localhost:9200/test/entry/_search?pretty=true' -d '{ 
  "query":{
    "custom_boost_factor" :{
      "query" : {
        "text_phrase_prefix" : {
          "title" : "test"
        }
      },
      "boost_factor": 2.0
    }
  }
}' 
相关问题