cant use toSearchableArray method
Closed this issue · 3 comments
bsormagec commented
I can't use toSearhableArray for eager loading. When I use eager loading features index not getting values. Any idea ?
public function toSearchableArray(): array
{
return [
$this->stock_code,
$this->category->name,
$this->name,
$this->description,
$this->status,
$this->is_online,
$this->is_active,
optional($this->brand)->name,
$this->mainProduct,
];
}
mmachatschek commented
Hi @bsormagec,
this is not MeiliSearch specific. And more of a laravel/scout issue. You can try to do:
public function toSearchableArray(): array
{
$this->load('brand');
return [
$this->stock_code,
$this->category->name,
$this->name,
$this->description,
$this->status,
$this->is_online,
$this->is_active,
optional($this->brand)->name,
$this->mainProduct,
];
}
bsormagec commented
I am checking it send post to meilisearch instance
32 => array:8 [
"stock_code" => "STCK12344321"
"category" => "Fruits"
"name" => "test variant1 name"
"description" => "test variant1 description"
"status" => 0
"is_online" => 0
"is_active" => null
"brand" => "Coogie"
]
but I can't see any record on meilisearch don't understand what is the problem. If I see $this->toArray() it works but when I try to manipulate array key's its not sending values to meilisearch. do you have an idea @mmachatschek
bsormagec commented
I fixed problem and sorry for disturbing :) I forgot to add id field to toSearchableArray Method :) thanks.