我在弹性搜索中遇到问题。在控制台Kibana中,我正在执行此代码,
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="icon-bar" style="float: left; height: 100%; background-color: #1C2336;">
<div class="activeIconBar iconBarItem" style="border-left: 2px #51B4C7 solid;"><a onclick="setActiveTab()" class="" href="#"><i class="fa fa-eye"></i> sada sd a</a>
</div>
<div class="iconBarItem" style="border-left: 2px #79AE16 solid;"><a onclick="setActiveTab()" class="" href="#"><i class="fa fa-user-o"></i>asasdasd<asdasd/a>
</div>
<div class="iconBarItem" style="border-left: 2px #6DC763 solid;"><a onclick="setActiveTab()" class="" href="#"><i class="fa fa-info-circle" aria-hidden="true"></i></a>
</div>
<div class="iconBarItem" style="border-left: 2px #0574E7 solid;"><a onclick="setActiveTab()" class="" href="#"><i class="fa fa-folder-open-o" aria-hidden="true"></i></a>
</div>
<div class="iconBarItem" style="border-left: 2px #5285BA solid;"><a onclick="setActiveTab()" class="" href="#"><i class="fa fa-calendar"></i></a>
</div>
<div class="iconBarItem" style="border-left: 2px #80BCFB solid;"><a onclick="setActiveTab()" class="" href="#"><i></i></a>
</div>
<div class="iconBarItem" style="border-left: 2px #FF8402 solid;"><a onclick="setActiveTab()" class="" href="#"><i class="fa fa-line-chart"></i></a>
</div>
<div class="iconBarItem" style="border-left: 2px #FFAE00 solid;"><a onclick="setActiveTab()" class="" href="#"><i class="fa fa-desktop"></i></a>
</div>
<div class="iconBarItem" style="border-left: 2px #FFDF61 solid;"><a onclick="setActiveTab()" class="" href="#"><i class="fa fa-users"></i></a>
</div>
<div class="iconBarItem" style="border-left: 2px #B147E9 solid;"><a onclick="setActiveTab()" class="" href="#"><i class="fa fa-user-times"></i></a>
</div>
</div>
我有这个结果。
GET bounce_gmd/_search
{
"query": { "match_phrase": { "date_added": "2017-02-08" } },
"size": 0,
"aggs": {
"date_added": {
"terms": {
"field": "bounce_type.keyword"
}
}
}
}
但是当我从我的laravel项目中跑出来时,我没有这个结果。 我的php代码看起来像这样,
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 129812,
"max_score": 0,
"hits": []
},
........................... and many more lines.
这里$ index_name ='bounce_gmd'和$ now_time =“2017-02-08”。
但答案是,
我将代码更改为,
$params['index'] = $index_name;
$params['type'] = $index_name;
$params['body'] = $json;
$params['body']['query']['match_phrase']['date_added'] = $now_time;
$params['body']['size']=0;
$params['body']['aggs']['bounce_type']['terms']['field']='bounce_type.keyword';
$response = $client->search($params);
但答案仍然是一样的。我不明白是什么问题。请帮我。
答案 0 :(得分:0)
为什么在0上指定大小?它应该有一些价值。您的聚合也可以包含可能的大小(每个aggs应该采用最大可能的选项)。工作查询的一些示例:
{
"from" : 0,
"size" : 10,
"query" : {
"match" : {
"body":
{
"query":"press key handler ",
"operator":"or",
"analyzer":"english"
}
}
},
"aggs" : {
"category_aggs" : { "terms" : { "field": "category", "size":25}},
"year_aggs" : { "terms" : { "field": "year", "size":30}},
"post_type_aggs" : { "terms" : { "field": "post_type", "size":2}}
}
}