gpt4 book ai didi

elasticsearch - 使用random_score的elasticsearch会降低性能

转载 作者:行者123 更新时间:2023-12-02 22:19:29 28 4
gpt4 key购买 nike

当我在查询中使用random_score时,我发现获取查询结果花费了大约150毫秒(如果不使用random_score,则需要花费250毫秒来获取结果)。

原始查询

{
"size": 10,
"query": {
"function_score": {
"query": {
"bool": {
"must": [
{
"query_string": {
"fields": [
"sound_title",
"album_title"
],
"query": "0"
}
}
]
}
},
"functions": [
{
"filter": {
"bool": {
"must": [
{
"term": {
"sound_chapters": 1
}
}
]
}
},
"weight": 1.2
},
{
"field_value_factor": {
"field": "album_playcount",
"modifier": "log",
"missing": "100"
}
}
],
"score_mode": "sum"
}
}
}

使用random_score 的 查询
{
"size": 10,
"query": {
"function_score": {
"query": {
"bool": {
"must": [
{
"query_string": {
"fields": [
"sound_title",
"album_title"
],
"query": "0"
}
}
]
}
},
"functions": [
{
"filter": {
"bool": {
"must": [
{
"term": {
"sound_chapters": 1
}
}
]
}
},
"weight": 1.2
},
{
"field_value_factor": {
"field": "album_playcount",
"modifier": "log",
"missing": "100"
}
},
{
"random_score": {
"seed": "123"
}
}
],
"score_mode": "sum"
}
}
}

有什么方法可以优化查询以提高性能?

最佳答案

如果要向任何ElasticSearch查询中添加更多功能,则ES将花费一些处理时间才能将该功能的分数包括在主分数中,从而增加了总体时间。
您可以在elasticsearch here中阅读有关随机评分的更多信息。

提高查询性能的最常见方法是在缓存过滤器时使用filters而不是query。但是,如果服务器中有足够的内存,则应这样做。

您可以从here博客中获得更多想法。

关于elasticsearch - 使用random_score的elasticsearch会降低性能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38717156/

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