Reputation: 2495
I am incorporating Algolia search in one of my applications and running into the 10 KB document size limit. I only want to index certain fields within my model and not the whole thing. I am using mongo and it has embedded and related documents that I dont care for.
I followed the instructions at: https://laravel.com/docs/5.3/scout
Now when I index the data, I get the warnings that about 100 out of my 2000 or so documents are over the 10 KB size.
How do I tell Algolia that I only want to index certain fields and ignore some of the other data like relationships or embedded documents ?
Upvotes: 0
Views: 113
Reputation: 1360
You can use the toSearchableArray
of Laravel in the class you're adding the searchable trait. In that you only include the parts that you actually want to search on.
public function toSearchableArray() {
$array = $this->toArray();
$array = [
'id' => $this->id,
'name' => $this->name,
'description' => $this->description,
'price' => (int)$this->price,
'likes' => (int)$this->likes,
'slug' => $this->slug
];
return $array;
}
Is that what you're looking for?
Upvotes: 1