Download the PHP package ahmedkhan847/mysqlwithelasticsearch without Composer
On this page you can find all versions of the php package ahmedkhan847/mysqlwithelasticsearch. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ahmedkhan847/mysqlwithelasticsearch
More information about ahmedkhan847/mysqlwithelasticsearch
Files in ahmedkhan847/mysqlwithelasticsearch
Package mysqlwithelasticsearch
Short Description A small package to connect MySQL with Elasticsearch
License MIT
Informations about the package mysqlwithelasticsearch
Connect MySQL With Elasticsearch using PHP
A small library to connect MySQL with Elasticsearch. Use it to sync data and do full text search.
Click here to find the API documentation for v2
Downloading the latest release
Clone the library
git clone -b release2 https://github.com/ahmedkhan847/mysqlwithelasticsearch
Now, run composer install
to install the required dependencies.
Or use composer to install complete package.
composer require ahmedkhan847/mysqlwithelasticsearch:2.*
What's in release2?
In release2 package is fully redesign. Now you don't need to pass $config file to constructor. You can set index, type, sql query, sql connection dyamically. Even now you can create your own function for searching in Elasticsearch. Let's see how you can achieve the following:
- Mapping in Elasticsearch
- Indexing All MySQL data in Elasticsearch
- Indexing All MySQL data in Elasticsearch using MySqli Connection
- Indexing Single Data in Elasticsearch
- Updating in Elasticsearch
- Deleting in Elasticsearch
- Searching in Elasticsearch
- Creating your own search class for Elasticsearch
Mapping in Elasticsearch
Indexing All MySQL data in Elasticsearch
By default it is using *"SELECT FROM tablename", use 'id'** as a default id column for table and elasticsearch. It is using PDO connection to fetch the data by default. If you want elasticsearch to fetch data using mysqli connection you can also use that you just need to set the connection to SyncMySql\Connection\MySQLiConnection
or write your own by implementing SyncMySql\Connection
. Also you can change the select query but don't forget to define an id column in it. Let's see how you can do it.
Indexing All MySQL data in Elasticsearch using MySqli Connection
Indexing Single Data in Elasticsearch
If you have want to define you own query then:
Updating in Elasticsearch
Using same technique as we do for insert you can add your own select query using setSqlQuery()
.
Deleting data from Elasticsearch
Searching in Elasticsearch
Creating your own search class for Elasticsearch
In order to write your own search you should extends it from SearchAbstract
class and complete the public function search($query)
in it.
If you want contribute, fork master branch.