我使用下面的代码和下面的错误连接php到elasticsearch我使用elasticsearch php客户端
$params = [
'index'=>'index1,index2',
'from'=>$startfrom,
'size'=>$maxperpage,
'sort' => array('id:desc'),
'body' => [
'query' => [
'query_string' => [
'query' => "\"$search_text\""
]
]
],
];
if($limit_time['start']){
$params['body']['query']['range']['date_insert']['gte']=$limit_time['start'];
}
if($limit_time['end']){
$params['body']['query']['range']['date_insert']['lte']=$limit_time['end'];
}
错误:
{"error":{"root_cause":[{"type":"parsing_exception","reason":"[query_string] malformed query, expected [END_OBJECT] but found [FIELD_NAME]","line":1,"col":104}],"type":"parsing_exception","reason":"[query_string] malformed query, expected [END_OBJECT] but found [FIELD_NAME]","line":1,"col":104},"status":400}
2条答案
按热度按时间s71maibg1#
你应该试试这样的。这个
query_string
以及range
查询需要合并到一个bool/filter
查询:fnatzsnv2#
我解决了这个问题,但非常感谢“瓦尔”的帮助
我使用以下代码: