gpt4 book ai didi

php - 相同查询的elasticsearch浏览器和php客户端的不同结果

转载 作者:行者123 更新时间:2023-12-02 23:35:45 25 4
gpt4 key购买 nike

我在下面运行此查询,并检查返回144条记录的结果,但是当我使用浏览器运行查询时,它不返回任何内容。我知道结果在任何情况下都必须相同,无论如何,此api都会像这样转换查询,但是结果不同并且无法理解原因

$elasticSearch = new Elasticsearch\Client(['hosts' => ['localhost:9200']]);
$params = array();
$json = '{
"query" : {
"match" : {
"logdata" : "_client_"
}
}
}';
$params['body'] = $json;
$params['index'] = 'accesslog_index';
$params['size'] = 400;
$query = $elasticSearch->search($params);

如果图像似乎没有:
浏览器中的网址: http://localhost:9200/accesslog_index/_search?pretty=true&q=logdata:_client_&size = 100
结果:
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 72,
"max_score" : 1.0,
"hits" : [ {
"_index" : "accesslog_index",
"_type" : "acceslogs_june",
"_id" : "AU6R267Wy2aRfwCng6-y",

...

最佳答案

这样做的主要原因是因为两个查询不相等。

在查询DSL中,http://localhost:9200/accesslog_index/_search?q=logdata:*_client_*的等效查询不是match查询,而是query_string查询,如下所示:

{
"query": {
"query_string" : {
"default_field" : "logdata",
"query" : "*_client_*"
}
}
}

official doc:

The query string “mini-language” is used by the Query String Query and by the q query string parameter in the search API.

关于php - 相同查询的elasticsearch浏览器和php客户端的不同结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31513741/

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