gpt4 book ai didi

elasticsearch - 提高特殊文档的等级

转载 作者:行者123 更新时间:2023-12-03 00:28:10 26 4
gpt4 key购买 nike

我有2种类型的文档索引:DistrictStreet。我想提高District文档的等级。

没有script选项,有没有办法做到这一点?

最佳答案

您可以使用custom_filters_score增强与过滤器匹配的文档,并且您的过滤器可以是type -filter。

这是一个可运行的示例,您可以使用:https://www.found.no/play/gist/8744808

#!/bin/bash

export ELASTICSEARCH_ENDPOINT="http://localhost:9200"

# Index documents
curl -XPOST "$ELASTICSEARCH_ENDPOINT/_bulk?refresh=true" -d '
{"index":{"_index":"play","_type":"district"}}
{"title":"there"}
{"index":{"_index":"play","_type":"street"}}
{"title":"there"}
'

# Do searches

curl -XPOST "$ELASTICSEARCH_ENDPOINT/_search?pretty" -d '
{
"query": {
"custom_filters_score": {
"query": {
"match": {
"title": {
"query": "there"
}
}
},
"filters": [
{
"boost": 2,
"filter": {
"type": {
"value": "district"
}
}
}
]
}
}
}
'

关于elasticsearch - 提高特殊文档的等级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21489407/

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