My code was running fine on ElasticSearch v2x. But upgrading to ElasticSearch v5.0.0 I get the following error when I output the results:
PHP {
"error" : {
"root_cause" : [
{
"type" : "parsing_exception",
"reason" : "no [query] registered for [filtered]",
"line" : 4,
"col" : 20
}
],
"type" : "parsing_exception",
"reason" : "no [query] registered for [filtered]",
"line" : 4,
"col" : 20
},
"status" : 400
}
Here's my actual PHP code:
$data_string = '{
"from" : 0, "size" : "' . $maximumResults . '",
"query" : {
"filtered" : {
"query" : {
"match" : {
"title" : {
"query" : "' . $searchWord1 . ' ' . $searchWord2 . ' ' . $searchWord3 . '",
"operator" : "and"
}
}
},
"filter" : {
"bool" : {
"must" : [
{
"term" : {
"node" : "' . $currentNodeId . '"
}
}
],
"must_not" : {
"term" : {
"discussion_id" : "' . $currentThreadId . '"
}
}
}
}
}
},
"sort": {
"date": {"order": "desc" }
}
}';
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string );
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
$results = curl_exec($ch);