gpt4 book ai didi

Perl Elastic 查询从 2.4 升级到 5 后损坏

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

如标题所示,我正在升级到 ES5。我原来的 ES 查询看起来像:

my $response = $elastic->do_request_new( 
{
query => {
filtered => {
filter => {
or => [
{ term => { _type => { value => "some_val1" } } },
{ term => { _type => { value => "some_val2" } } },
]
},
query => {
query_string => {
query => $qstring,
rewrite => "scoring_boolean",
analyze_wildcard => "true",
}
}
}
},

sort => [ qw(_score) ],
size => 50,
},
);

我更新后的样子:

my $response = $elastic->do_request_new(
{
query => {
bool => {
should => [
{ term => { _type => { value => "some_val1" } } },
{ term => { _type => { value => "some_val2" } } },
],
must => {
query_string => {
query => $qstring,
rewrite => "scoring_boolean",
analyze_wildcard => "true",
}
}
}
},
sort => [ qw(_score) ],
size => 50,
},
);

但是,在我的弹性数据库中搜索精确的字符串时,我返回的结果为零:

{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}

对可能发生的事情有什么想法吗?我的猜测是我的查询结构有误。谢谢!

最佳答案

更新:以下固定查询:

my $response = $elastic->do_request_new(
{
query => {
bool => {
must => [
{
query_string => {
query => $qstring,
rewrite => "scoring_boolean",

analyze_wildcard => "true",
},
}
],
filter => {
bool => {
should => [
{ term => { _type => { value => "some_val1" } } },
{ term => { _type => { value => "some_val2" } } },

],
},
},
},
},
sort => [ qw(_score) ],
size => 50,
},
);

关于Perl Elastic 查询从 2.4 升级到 5 后损坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46573263/

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