jeudi 2 mars 2017

Elasticsearch- laravel multiple range

I want to get all product where name = $query and minrate between 0-49 et 50-99 I test this but not working $brans = request()->priceFilter; if(!empty($brans)):

        $product = "";
         foreach($brans as $data){
           $minMax = explode("-",$data);
            if(count($minMax)==2){
           $product[] = Afica::search()
                ->multiMatch(['name','city_hotel'], $query, ['fuzziness' => 'AUTO'])
                ->must()
                ->term()
                 ->range('minrate',['from'=>0,'to'=>49])
                ->range('minrate',['from'=>50,'to'=>99])
                ->sortBy('minrate','asc'); 
        }

    }
    $books = $product[0];
    for($i=1;$i<count($product);$i++){
        $books= $books->$product[$i]
                ->paginate(25);

    }
    if ($request->ajax())
    {
            return view('presult', compact('books'));
    }
   return view("welcome")->with('books',$books);
   else:
    $books = Afica::search()
        ->paginate(26);
 return view("welcome")->with('books',$books);

endif;



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire