Wednesday, October 1, 2014

Day 5: Accessing elasticsearch using PHP

26.092014

I was given access to MySQL database on the trial server. I created a database and some tables on that server and tried to import the data on MySQL server into elasticsearch. I ran off track a couple of times. But by the end of the day I managed to import the MySQL table data into elasticsearch.

MySQL database is like an index in elasticsearch and a MySQL table is like a type in elasticsearch. A record in a row is stored as an object and is referred using an id in elasticsearch. I took the MySQL row data into a PHP array and encoded it into a json object and passed it into elasticsearch.

Another way to add data to elasticsearch is using a PHP client. However here I used a cURL, accessing using command line in PHP to insert the data into elasticsearch.

No comments:

Post a Comment