elasticsearch - 在 elasticsearch 渗透响应中评分

标签 elasticsearch elasticsearch-percolate

现状

我正在使用 elasticsearch 的过滤功能。它运行良好 - 我为新文档获取了匹配的 percolate-ids,并且基本上可以构建反向搜索。到目前为止一切都很好。

问题

问题来了:我想要一个分数来表示给定文档与过滤器查询的匹配程度(正是正常查询给我的分数)。为此,我添加了 track_scores,但没有成功。

我在 track_scores 的文档中找到了这个:

...The score is based on the query and represents how the query matched to the percolate query’s metadata and not how the document being percolated matched to the query...

我想要/需要的东西是可能的吗?

显示问题的示例

这里是演示问题的示例(取自 elasticsearch.org )。这里渗透响应中返回的分数始终是 1.0,无论输入文档如何:

//Index the percolator
curl -XPUT 'localhost:9200/my-index/.percolator/1' -d '{
    "query" : {
        "match" : {
            "message" : "bonsai tree"
        }
    }
}'

过滤第一个文档:

curl -XGET 'localhost:9200/my-index/message/_percolate' -d '{
    "doc" : {
        "message" : "A new bonsai tree in the office"
    },
    "track_scores" : "true"
}'


//...returns
{"took": 1, "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
}, "total": 1, "matches": [
    {
        "_index": "my-index",
        "_id": "1",
        "_score": 1.0 <-- Score
    }
]}

过滤第二个(不同的):

//Percolate a second one
curl -XGET 'localhost:9200/my-index/message/_percolate' -d '{
    "doc" : {
        "message" : "A new bonsai tree in the office next to another bonsai tree is cool!"
    },
     "track_scores" : "true"
}'


//...returns
{"took": 3, "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
}, "total": 1, "matches": [
    {
        "_index": "my-index",
        "_id": "1",
        "_score": 1.0 <-- SAME Score, but different document (other score needed here!)
    }
]}

我需要什么

我希望第一个文档的得分类似于 0.8,第二个文档的得分类似于 0.9。但是他们不能像在这里那样获得相同的分数。我怎样才能实现我想要的?

非常感谢任何想法和帮助。

最佳答案

分数是相对于数据集中其他文档的。您可能会进行某种自定义评分,您只关注手头文档的术语频率/逆向文档频率,但可能不会非常有效,但可能已经足够好了。

我不确定这是否是解决您的问题的可行方法,但一种方法是针对整个数据集重新运行所有匹配的渗透查询,并从中获取您的文档分数并用它重新索引文档数据。由于它都是相对的,因此这可能需要您随后更新与查询匹配的所有其他文档。可能最好在某个设定的时间间隔内进行全局重新评分。

关于elasticsearch - 在 elasticsearch 渗透响应中评分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24335715/

相关文章:

elasticsearch - 在Elasticsearch中分页渗滤结果

docker - 重新启动后docker容器不起作用

elasticsearch - 基于Elasticsearch警报的通知

elasticsearch - 如何删除 Elasticsearch 索引中的所有渗透器查询

c# - 当每个索引只能有一个映射时,将渗透器存储在单独的索引中吗?

elasticsearch - Elasticsearch 5.2.2 Raspberry Pi 3低CPU内存优化

elasticsearch - 关于Elasticsearch文档的混淆,有关包含 bool 查询的json

elasticsearch - Elastic Search 自动翻转索引

c# - ElasticSearch.net与查询的嵌套匹配不起作用