正如标题所示,我正在升级到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" } } },],must => { query_string => { query => $qstring,} } } },);
{ "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",} ],filter => { bool => { should => [ { term => { _type => { value => "some_val1" } } },{ term => { _type => { value => "some_val2" } } },);