# Elasticsearch how to retrieve table values from mysql and PHP

**URL:** <https://discuss.elastic.co/t/elasticsearch-how-to-retrieve-table-values-from-mysql-and-php/28903>\
**Category:** Elasticsearch\
**Created:** [September 9, 2015, 7:17am UTC](https://discuss.elastic.co/t/elasticsearch-how-to-retrieve-table-values-from-mysql-and-php/28903 "2015-09-09T07:17:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![satheeshkumar07](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@satheeshkumar07](https://discuss.elastic.co/u/satheeshkumar07)\
**Post date:** [September 9, 2015, 7:17am UTC](https://discuss.elastic.co/t/elasticsearch-how-to-retrieve-table-values-from-mysql-and-php/28903/1 "2015-09-09T07:17:43Z")

</div>

I have installed Elastisaerch and MySQL jdbc driver in my localhost. I have verified it was working fine. After that I have updated the database and table properties using below parameters.

```
{
    "type" : "jdbc",
    "jdbc" : {
        "driver" : "com.mysql.jdbc.Driver",
        "url" : "jdbc:mysql://localhost:3306/elastisearch",
        "user" : "elastic",
        "password" : "pass@123",
        "sql" : "select `mytable`.`id` as `_id`, `mytable`.`firstname`, `mytable`.`lastname` from mytable",
        "poll" : "1h",
        "scale" : 0,
        "autocommit" : false,
        "fetchsize" : 100,
        "max_rows" : 0,
        "max_retries" : 3,
        "max_retries_wait" : "10s",
        "locale" : "in",
        "digesting" : true 
    }
}

```

this was updated by using curl -XPOST [http://localhost:9200/myindex/mytype/\_meta](http://localhost:9200/myindex/mytype/_meta) and i received below message

```
 {
  "_index": "myindex",
  "_type": "mytype",
  "_id": "_meta",
  "_version": 1,
  "created": true
}

```

I have verified in command prompt with below code

```
curl -XGET localhost:9200/myindex/_search?pretty

```

and I received below message

```
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "myindex",
      "_type" : "mytype",
      "_id" : "_meta",
      "_score" : 1.0,
      "_source":{
    "type" : "jdbc",
    "jdbc" : {
        "driver" : "com.mysql.jdbc.Driver",
        "url" : "jdbc:mysql://localhost:3306/elastisearch",
        "user" : "elastic",
        "password" : "Ppts@123",
        "sql" : "select `mytable`.`id` as `_id`, `mytable`.`firstname`, `mytable
`.`lastname` from mytable",
        "poll" : "1h",
        "scale" : 0,
        "autocommit" : false,
        "fetchsize" : 100,
        "max_rows" : 0,
        "max_retries" : 3,
        "max_retries_wait" : "10s",
        "locale" : "in",
        "digesting" : true
    }
}
    } ]
  }
}

```

I need to check the values with some search queries how can i check the results with Elastic-search? please give me one sample to view the value in MySQL table.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 10, 2015, 9:40am UTC](https://discuss.elastic.co/t/elasticsearch-how-to-retrieve-table-values-from-mysql-and-php/28903/2 "2015-09-10T09:40:00Z")

</div>

You can't just add that to ES and expect it to connect to a database.

You need to use the Logstash [JDBC input](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:51pm UTC](https://discuss.elastic.co/t/elasticsearch-how-to-retrieve-table-values-from-mysql-and-php/28903/3 "2017-07-05T23:51:21Z")

</div>


