laravel-scout-tntsearch-driver icon indicating copy to clipboard operation
laravel-scout-tntsearch-driver copied to clipboard

Question: Weights and json attributes in Where clause?

Open timramseyjr opened this issue 8 years ago • 1 comments

I just found your driver and want to thank you for the great work. I was going through the documentation and didn't see anything, but thought I would ask considering I am a search noobie.

  1. Is there any way to weight columns? i.e - If the search phrase was found in the name column it would carry more weight than in the description.
  2. I have a Postgres jsonb column 'attributes' is there anyway to do something like Model::search('something')->where('attributes->gender','male')->get();

timramseyjr avatar Aug 19 '17 00:08 timramseyjr

For 2. I tried to move the attributes array pieces to the original array in the toSearchableArray on the model, but still no luck

public function toSearchableArray(){
        $array = $this->toArray();
        foreach($array as $key => $value){
            if(is_array($value)){
                foreach($value as $k => $v){
                    $array[$k] = $v;
                }
                unset($array[$key]);
            }
        }
        return $array;
    }

timramseyjr avatar Aug 19 '17 15:08 timramseyjr