一个查询问题 久久不能解惑望大神搭救于水火
匿名 | 发布于2017年09月08日 | 阅读数:4062
								我想筛选出一个用户 一个时间段内的所有记录:条件有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}
 
	
3 个回复
novia - 1&0
赞同来自:
Cheetah
赞同来自:
Abyss - 90后IT男
赞同来自:
expected [END_OBJECT] but got [FIELD_NAME], possibly too many query clauses,错误提示也很明显啊,需要结束,而不是另一个语法声明啊。