0

Can I add a part of the fields of an table to the index of algolia

For example:

There is a table articles,it's fileds like this: id title content author status created_at updated_at deleted_at

I only want to add the 4 fileds id title content author to the index of algolia,

I read the docs of Scout in Laravel 5.3,it seems not to be mentioned.

zwl1619
  • 4,002
  • 14
  • 54
  • 110

1 Answers1

1

You need to implement the toSearchableArray method on your model.

public function toSearchableArray()
{
  return [
       'objectID' => $this->id,
       'title' => $this->title,
       'content' => $this->content,
       'author' => $this->author,
    ]
}
Max
  • 251
  • 1
  • 4