3

I've installed and configured meilisearch + Laravel Scout package.

My Model:

class Post extends Model
{
    use Searchable;
}

When I run php artisan scout:import 'App\Models\Post' it returns:

Imported [App\Models\Post] models up to ID: 5
All [App\Models\Post] records have been imported.

But when I check the index, it's empty. Why?

The index is being created, but the data doesn't get imported.

The same configuration of meilisearch and Scout package, works for some other models.

X 47 48 - IR
  • 1,250
  • 1
  • 15
  • 28
  • Hi! What does the update status return? https://docs.meilisearch.com/reference/api/updates.html#get-all-update-status – CaroFG Aug 02 '21 at 12:31

3 Answers3

9

I've just run into this issue myself and came across your question. I don't suppose you're specifying what should be stored in the index are you?

I.e. in your model, have you created a toSearchableArray method like the below...

public function toSearchableArray(): array
{
    return [
        'name' => $this->name,
    ];
}

If you have, it turns out that your toSearchableArray method must also return the primary key within the array, otherwise the record does not get indexed.

public function toSearchableArray(): array
{
    return [
        'id'   => $this->getKey(), // this *must* be defined
        'name' => $this->name,
    ];
}
Chris
  • 1,939
  • 1
  • 19
  • 38
5

You can try to set:

SCOUT_QUEUE=false

To check that there is no issue with your queues and run the import again.

rccode
  • 51
  • 3
3

For index you can try:

php artisan scout:index posts

There is no other issue with your queues and run the import again.

If you have SCOUT_QUEUE=true then please, start your queue using php artisan queue:work --daemon and your data will be start importing.