Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

importing database table to algolia

At algolia website i found this code but it is not adding any index at the algolia website. i am working fine with a search for an index that algolia provides ""getstarted_actors"". but i want to import my own database data to be created as index. please help

The following code adds search capabilities to your Contact model creating a Contact index:

    use Illuminate\Database\Eloquent\Model;
    use AlgoliaSearch\Laravel\AlgoliaEloquentTrait;

    class Contact extends Model 
    { use AlgoliaEloquentTrait;
     }
like image 212
Ahmed Nawaz Khan Avatar asked Mar 12 '23 09:03

Ahmed Nawaz Khan


1 Answers

In order to initially import your data into Algolia you need to use the reindex added by the AlgoliaEloquentTrait on your model. This is because the autoindex feature is only triggered after you make changes, so the initial import has to be done manually.

This will look like:

YourModel::reindex();
like image 119
bobylito Avatar answered Apr 25 '23 05:04

bobylito