# Needed each row as a separate document with the columns as field

**URL:** <https://discuss.elastic.co/t/needed-each-row-as-a-separate-document-with-the-columns-as-field/118304>\
**Category:** Logstash\
**Created:** [February 3, 2018, 9:49am UTC](https://discuss.elastic.co/t/needed-each-row-as-a-separate-document-with-the-columns-as-field/118304 "2018-02-03T09:49:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Darpan\_Kukreja](https://avatars.discourse-cdn.com/v4/letter/d/848f3c/32.png) [@Darpan\_Kukreja](https://discuss.elastic.co/u/Darpan_Kukreja)\
**Post date:** [February 3, 2018, 9:49am UTC](https://discuss.elastic.co/t/needed-each-row-as-a-separate-document-with-the-columns-as-field/118304/1 "2018-02-03T09:49:06Z")

</div>

Hi,we are planning to implement elasticsearch for retrieving records,we have already installed elasticsearch which is working fine

abhishek@CASSANDRA02 star\_sd\_24jan]$ curl -X GET '[http://localhost:9200](http://localhost:9200)'  
{  
"name" : "node-1",  
"cluster\_name" : "my-application",  
"cluster\_uuid" : "5VEbDq8NQ4ufkbDEmsuAYw",  
"version" : {  
"number" : "6.1.3",  
"build\_hash" : "af51318",  
"build\_date" : "2018-01-26T18:22:55.523Z",  
"build\_snapshot" : false,  
"lucene\_version" : "7.1.0",  
"minimum\_wire\_compatibility\_version" : "5.6.0",  
"minimum\_index\_compatibility\_version" : "5.0.0"  
},  
"tagline" : "You Know, for Search"  
}

and we have to select records from table name:events in database name:test at faster rate.We have also installed logstash for communicating between elasticsearch and Mysql.Please find below configuration in logstash.conf

input {  
jdbc {  
jdbc\_connection\_string =\> "jdbc:mysql://localhost:3306/test"

# The user we wish to execute our statement as

jdbc\_user =\> ""  
jdbc\_password =\> ""

# The path to our downloaded jdbc driver

jdbc\_driver\_library =\> "/home/abhishek/Downloads/mysql-connector-java-5.1.45/mysql-connector-java-5.1.45-bin.jar"  
jdbc\_driver\_class =\> "com.mysql.jdbc.Driver"

# our query

statement =\> "SELECT \* FROM events"  
}  
}  
output {  
stdout { codec =\> json }  
elasticsearch {  
"hosts" =\> "localhost:9200"  
"index" =\> "test-migrate"  
"document\_type" =\> "data"  
}  
}

but running curl -XPOST -H 'Content-Type: application/json' '[http://localhost:9200/test-migrate/\_search?pretty=true](http://localhost:9200/test-migrate/_search?pretty=true)' -d '{}',we are getting this output  
{  
"took" : 229,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"skipped" : 0,  
"failed" : 0  
},  
"hits" : {  
"total" : 3,  
"max\_score" : 1.0,  
"hits" : [  
{  
"\_index" : "test-migrate",  
"\_type" : "pretty=true",  
"\_id" : "kOG5WmEBiAKb5bnD-zow",  
"\_score" : 1.0,  
"\_source" : { }  
},  
{  
"\_index" : "test-migrate",  
"\_type" : "pretty=true",  
"\_id" : "keG7WmEBiAKb5bnDUDqN",  
"\_score" : 1.0,  
"\_source" : { }  
},  
{  
"\_index" : "test-migrate",  
"\_type" : "pretty=true",  
"\_id" : "kuH8WmEBiAKb5bnDwTqV",  
"\_score" : 1.0,  
"\_source" : { }  
}  
]  
}  
}

whereas we needed each row as a separate document with the columns as field

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 3, 2018, 10:03am UTC](https://discuss.elastic.co/t/needed-each-row-as-a-separate-document-with-the-columns-as-field/118304/2 "2018-02-03T10:03:40Z")

</div>

Please format your code using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and not the citation button. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

Please edit your post.

I moved your question to #logstash

---

<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:** [March 3, 2018, 10:03am UTC](https://discuss.elastic.co/t/needed-each-row-as-a-separate-document-with-the-columns-as-field/118304/3 "2018-03-03T10:03:52Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
