Closed jackkitley closed 2 months ago
Hi, this package maps a Laravel Model to an OpenSearch Index the same way a normal Laravel model (that connects to say MySQL) maps to a table. That's it.
The package then allows you to search and query your OpenSearch index using the same (and more) eloquent/query builder methods as if it were native to Laravel. You work with your OpenSearch model independently of MySQL or any other connections you have.
There are many use cases for this, the main one being to index an existing SQL-based table/model to an OpenSearch model. Example:
User::class
model in MySQLIndexedUser::class
model in OpenSearch (using this package)Then create observers to watch your User
model and trigger a build/rebuild on IndexedUser
You can now use all the search and query methods to search IndexedUser
, see:
You can also tie IndexedUser
back to User
with relationships: https://opensearch.pdphilip.com/os-mysql
It's a low-level package and up to you, the developer, how to implement it. Enjoy!
@pdphilip
Thank you.
It just doesnt make sense to me that i create a record using my model and then it doesnt save to the table but rather straight to the opensearch instance.
My thought process would be to create a record, it saves to mysql and then an observer listens and creates a record on opensearch.
Opensearch then becomes the default for searching but then i would do a full re-index based on the eloquent models data (mysql) with a cron for example.
Thanks
Im not sure if this is correct but i could use the package with 2 models.
class Vehicles extends Illuminate\Database\Eloquent\Model
{
//Use this to create to mysql
}
class OpenSearchVehicles extends PDPhilip\OpenSearch\Eloquent\Model
{
protected $connection = 'opensearch';
//Use this for open search queries for grids, search results
}
To index:
$vehicles = Vehicle::all();
loop through this and do:
OpenSearchVehicles::create($vehicles from above)
I wanted to understand the integration a bit more.
Ive used it in my project and when i create a new project it saves the record to my opensearch instance.
The problem is , is that it doesnt save a hard copy to my mysql table?
Not sure if im doing this right.
If data is lost on on aws opensearch then there will be a sync issue and also lost data.