0
votes

I can't get scout working properly with algolia.

I added the client relationship to the searchable array:

public function toSearchableArray()
   {
      $this->client;

      $array = $this->toArray();

       $array = $this->transform($array);

       return $array;
   }

And want to search for these attributes:

'searchableAttributes' => ['title', 'description', 'client.naam', 'client.email'],

when i do:

Project::search($keyword)->where('user_id', $request->user_id)->where('finished', true)->orderBy('created_at', 'DESC')->paginate(10);

i don't get any result. Everything is imported en synced correctly al well.

But the records are uploaded to algolia en indexed correctly and when i search in the algolia dashboard i get the correct results. Does anyone know what i'm doing wrong?

1

1 Answers

0
votes

You’ve said your searchableAttributes are ['title', 'description', 'client.naam', 'client.email']

Then you’ve said you’re trying to search using 'user_id' and 'finished'.

If that’s correct, then you need to add user_id and finished to your searchableAttributes so that they are searchable.