mailerlite / laravel-elasticsearch

An easy way to use the official Elastic Search client in your Laravel applications.
MIT License
918 stars 187 forks source link

How to use #78

Closed nicolasvahidzein closed 4 years ago

nicolasvahidzein commented 4 years ago

Hello, thank you for taking the time to make this package but it seems many of us are having a hard time using this package. The other ones seems abandonned.

Your read me for some how has never used ES is not easy to grasp. We do not know where to execute the code. The install instructions are good, thanks for that, but not the usage.

Where do we put the indexing code? I have no idea what the type and index is, can you not just do a quick example with a sample model and show us?

That would be highly appreciated. Thanks.

petercoles commented 4 years ago

The key part of your question is probably that you're unfamiliar with ES. This is just a thin wrapper around ES to make it easier to use in a Laravel context, so where you use it will depend on your Laravel application and which features of ES you're using, rather than this package. So it's not really possible for @cviebrock to provide much in the way of samples.

As general guidance though, for basic saving and retrieval (by index or search) of records, put your code in the same places as you would if you were accessing a SQL-based database. So for a simple application you perform these operations in a controller. For more complex applications you might abstract them to a model (that doesn't need to extend the base Laravel model) or to a data repository.

I hope that helps.

nicolasvahidzein commented 4 years ago

Thanks Peter for taking the time but in the end, ES is not that complicated and even if it's a wrapper a sample example would be the minimum to provide for people like us. I ended up using the source package and figuring it out with a fleshed out tutorial.

cviebrock commented 4 years ago

@nicolasvahidzein : if you wanted to make a PR with some examples, I'd be happy to merge it in for future users.

Unfortunately, I'm not working on any projects that use this package or ES currently, so it's not really easy for me to do so.

nicolasvahidzein commented 4 years ago

Thank you buddy, i appreciate it. I'm working on something else at the moment. If i have time as well i will revert back to you. Cheers.