ELK,萌萌哒

一个查询问题 久久不能解惑望大神搭救于水火

匿名 | 发布于2017年09月08日 | 阅读数:3376

我想筛选出一个用户 一个时间段内的所有记录:条件有uid  时间段范围,请看下面我的实现代码。
    public function ceshi33($uid,$arr = []){
$index = array(
'index' => 'ul_live_d',
'body' => array(
'query' => array(
'filtered'=>array(
'filter'=>array(
'bool'=>array(
'must'=>array(
'match'=>array(
'uid'=>$uid,
),
'range' => array(
'ymd' => array(
'gte'=>'20170828',
'lte'=>'20170901',
),
),
),
),
),
),
),
'sort' => array(
'ymd' => array(
'order' => 'desc'
)
),
'size' => 100
)
);
if($arr) $index['_source']=$arr;
$rtn = $this->client->search($index);
if (isset($rtn['hits']) && count($rtn['hits']['hits'])) {
return $rtn['hits']['hits'];
}
return false;
}

抛出错误如下
{"error":{"root_cause":[{"type":"query_parsing_exception","reason":"expected [END_OBJECT] but got [FIELD_NAME], possibly too many query clauses","index":"ul_live_d_v4","line":1,"col":75}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"ul_live_d_v4","node":"JHMA96A3RoKm7Cs0a09Ozg","reason":{"type":"query_parsing_exception","reason":"expected [END_OBJECT] but got [FIELD_NAME], possibly too many query clauses","index":"ul_live_d_v4","line":1,"col":75}}]},"status":400}


QQ图片20170908152813.png

 
已邀请:

novia - 1&0

赞同来自:

把查询转成json提供下吧,看起来方便

Cheetah

赞同来自:

查询条件里如果是类型in的查询,值最多不能超过1024个,你传入的uid是不是超过这个了,如果超过了自己判断一下,然后查询多次

Abyss - 90后IT男

赞同来自:

bool.must里面是二维数组啊,你这个整成一维数组肯定有问题啊。
expected [END_OBJECT] but got [FIELD_NAME], possibly too many query clauses,错误提示也很明显啊,需要结束,而不是另一个语法声明啊。
'bool'=>array(
'must'=>array(
array(
'match'=>array(
'uid'=>$uid,
),
),
array(
'range' => array(
'ymd' => array(
'gte'=>'20170828',
'lte'=>'20170901',
),
),
)
),
),

要回复问题请先登录注册