Skip to content

Commit

Permalink
Fixed bug in translateFilter
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Escribano <[email protected]>
  • Loading branch information
carlosescri committed May 27, 2015
1 parent 3c213fe commit 7a7af7c
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions lib/doofinder_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function __construct($hashid, $api_key, $fromParams=false, $init_options = array
{
$this->fromQuerystring();
}

}

private function addprefix($value){
Expand All @@ -131,22 +131,21 @@ private function addprefix($value){
* translates a range filter to the new ES format
* 'from'=>9, 'to'=>20 to 'gte'=>9, 'lte'=>20
*
* @param array $filter
* @param array $filter
* @return array the translated filter
*/
private function translateFilter($filter){
$translated = array();
foreach($filter as $keey => $value){
if($keey == 'from'){
$t_key = 'gte';
} else if($keey == 'to'){
$t_key = 'lte';
$new_filter = array();
foreach($filter as $key => $value){
if ($key === 'from') {
$new_filter['gte'] = $value;
} else if ($key === 'to') {
$new_filter['lte'] = $value;
} else {
$t_key = $keey;
$new_filter[$key] = $value;
}
$translated[$t_key] = $value;
}
return $translated;
return $new_filter;
}

private function reqHeaders(){
Expand All @@ -161,7 +160,7 @@ private function apiCall($params){
$args = http_build_query($this->sanitize($params)); // remove any null value from the array
$url = $this -> url . '/' . $this->apiVersion . '/search?' . $args;
$session = curl_init($url);
curl_setopt($session, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($session, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($session, CURLOPT_HEADER, false); // Tell curl not to return headers
curl_setopt($session, CURLOPT_RETURNTRANSFER, true); // Tell curl to return the response
curl_setopt($session, CURLOPT_HTTPHEADER, $this->reqHeaders()); // Adding request headers
Expand Down

0 comments on commit 7a7af7c

Please sign in to comment.