scout-extended
scout-extended copied to clipboard
Laravel search records by id
Is there any good way to search records by id?
this is what i get:
`public function toSearchableArray() {
$array = $this->toArray();
$array['ticket_number'] = strval($this->id);
// some other code
return $array;
}
`
At the moment a created an extra array element "ticket_number", but this doesn't work properly, please can someone help me?
Hi @matthiasvanwoensel ,
Could you explain a bit more what exactly isn't working properly?
The code you sent should add the ticket_number
attribute to your records. Please keep in mind you need to add the ticket_number
attribute to your searchableAttributes in order for Algolia to search into the values here.
Thank you in advance!
Hi @matthiasvanwoensel ,
Could you explain a bit more what exactly isn't working properly?
The code you sent should add the
ticket_number
attribute to your records. Please keep in mind you need to add theticket_number
attribute to your searchableAttributes in order for Algolia to search into the values here.Thank you in advance!
I cant search in numbers, only in strings ...
I have a field ticket number and a field client_number, both are numbers, but if i for example wants to search a client number (1001 or something like that), i don't get records... while it in the table exists..
` public function searchClients($term) { $clients = Client::search($term); return $clients->orderBy('client_number', 'desc')->paginate(25);
}
Are these attributes configured as searchableAttributes
? Could you show us the settings of your index, please? 😄