adamfairholm / Elasticquent

Map Larvel Eloquent models to Elasticsearch types
MIT License
201 stars 38 forks source link

Indexing models question #9

Closed Sparo closed 9 years ago

Sparo commented 10 years ago

Hi,

I am sorry about, maybe newbe question (I am beginner in this) but I am not sure how to use elasticquent...

so I did installed it into my app, elasticsearch also working fine, but not sure how to index data from model/s, tables? I have put

**use Elasticquent\ElasticquentTrait**;

class ModelName extends Eloquent {

    **use ElasticquentTrait;**

}

into models, and now I am confused what next..

Do I need some new route which I would fire up and then in that route app will execute ModelName::addAllToIndex() or some other way... And how to update index? is it going to do it by itself or I need something do execute with cron or something...

Tnx in advance for answer...

adamfairholm commented 10 years ago

Hi Sparo!

Where/when you index your models (either individually or in a batch), is really up to where it makes the most sense in your application. You could set it up so that you index every time your model is updated (something I'd like to add for a future release), and you could also do it through a command line argument, or as part of another function. The idea behind it is you'd want to index it at different times in different ways, so it doesn't assume anything about how you want to index.

Adam

Sparo commented 9 years ago

tnx