gpt4 book ai didi

elasticsearch - 如何在 ElasticSearch 的 bool 查询中获取底层匹配查询的分数?

转载 作者:行者123 更新时间:2023-11-29 02:57:02 24 4
gpt4 key购买 nike

我有一个非常复杂的搜索,我基本上是在执行一个大型搜索,以查找与一组许多实体中的至少一个实体匹配的文章。

我注意到,随着我添加更多实体,分数会发生显着变化,因为我的 should 子句变大了。

这是我对 2 个实体的查询示例:

{
"size": 50,
"track_scores": true,
"min_score": 0.05,
"sort": [
{
"timestamp": {
"order": "desc"
}
}
],
"query": {
"bool": {
"should": [
{
"bool": {
"should": [
{
"function_score": {
"functions": [
{
"boost_factor": 1000000
}
],
"query": {
"terms": {
"relatedProfiles": [
"SomethingElse/124026966662",
"SomeLocation/707765"
]
}
},
"boost_mode": "replace"
}
},
{
"bool": {
"should": [
{
"multi_match": {
"type": "phrase",
"query": "Generic Systems",
"operator": "and",
"fields": [
"content.title",
"content.description"
]
}
},
{
"multi_match": {
"type": "phrase",
"query": "Generic Systems, Inc.",
"operator": "and",
"fields": [
"content.title",
"content.description"
]
}
}
],
"minimum_should_match": "1"
}
}
],
"minimum_should_match": "1",
"_name": "0e7da739-1d18-448b-caa2-5c615a59d108"
}
},
{
"bool": {
"should": [
{
"function_score": {
"functions": [
{
"boost_factor": 1000000
}
],
"query": {
"terms": {
"relatedProfiles": [
"SomeLocation/162479",
"SomethingElse/32b95cc3-a363-47c3-2ac1-86fdb3b7d108"
]
}
},
"boost_mode": "replace"
}
},
{
"bool": {
"should": [
{
"multi_match": {
"type": "phrase",
"query": "SomeBusiness Computer Inc",
"operator": "and",
"fields": [
"content.title",
"content.description"
]
}
},
{
"multi_match": {
"type": "phrase",
"query": "SomeBusiness, Inc",
"operator": "and",
"fields": [
"content.title",
"content.description"
]
}
}
],
"minimum_should_match": "1"
}
}
],
"minimum_should_match": "1",
"_name": "00cc4b36-ce6b-4816-e61e-b7124344d108"
}
}
],
"minimum_should_match": "1"
}
},
"filter": {
"bool": {
"must": [
{
"bool": {
"should": [
{
"bool": {
"must": [
{
"term": {
"type": "News"
}
},
{
"terms": {
"language": [
"eng"
]
}
}
]
}
},
{
"terms": {
"type": [
"Social",
"Job",
"Unknown"
]
}
}
]
}
},
{
"range": {
"timestamp": {
"lt": "2015-05-13T09:25:40.605",
"gt": "2013-05-13T09:25:40.605"
}
}
}
]
}
}
}

我怎样才能让基础匹配成为分数?或者,至少,名称查询下方部分的分数?

最佳答案

也许 https://elastic.co/webinars/elasticsearch-query-dsl有一些见解;在视频的后面,他谈到了 Dis Max 查询

来自 https://www.elastic.co/guide/en/elasticsearch/reference/1.5/query-dsl-dis-max-query.html

"We want the primary score to be the one associated with the highest boost, not the sum of the field scores (as Boolean Query would give)."

关于elasticsearch - 如何在 ElasticSearch 的 bool 查询中获取底层匹配查询的分数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30250981/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com