laravel-scout-tntsearch-driver
laravel-scout-tntsearch-driver copied to clipboard
Question: Weights and json attributes in Where clause?
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.
- 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.
- I have a Postgres jsonb column 'attributes' is there anyway to do something like Model::search('something')->where('attributes->gender','male')->get();
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;
}