# No hits after indexing Mysql

**URL:** <https://discuss.elastic.co/t/no-hits-after-indexing-mysql/182463>\
**Category:** Logstash\
**Created:** [May 23, 2019, 2:08pm UTC](https://discuss.elastic.co/t/no-hits-after-indexing-mysql/182463 "2019-05-23T14:08:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gonzalo\_Garcia\_Roces](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gonzalo_garcia_roces/32/46713_2.png) [@Gonzalo\_Garcia\_Roces](https://discuss.elastic.co/u/Gonzalo_Garcia_Roces)\
**Post date:** [May 23, 2019, 2:08pm UTC](https://discuss.elastic.co/t/no-hits-after-indexing-mysql/182463/1 "2019-05-23T14:08:19Z")

</div>

Hello I'm fairly new to ES and I'm not quite sure what is not working here.

I have indexed a Mysql table with the following logstash config.

> input {  
> jdbc {  
> jdbc\_connection\_string =\> "jdbc:mysql://127.0.0.1:3306/?user=root"  
> jdbc\_user =\> "root"  
> jdbc\_validate\_connection =\> true  
> jdbc\_driver\_library =\> "C:/Users/ggarciro/Documents/elastic/logstash-7.1.0/lib/mysql-connector-java-8.0.16.jar"  
> jdbc\_driver\_class =\> "com.mysql.cj.jdbc.Driver"  
> statement =\> "SELECT \* FROM employees.employees where gender = 'M'"  
> }  
> }  
> output {  
> elasticsearch {  
> index =\> "male\_employees"  
> document\_id =\> "%{id}"  
> hosts =\> ["localhost:9200"]  
> user =\> "elastic"  
> password =\> "elastihusky"  
> }  
> stdout{ codec =\> json\_lines}  
> }

However when i try to do a simple get as for example.

> GET /male\_employees/\_search  
> {  
> "query": {  
> "match": {  
> "first\_name": "Zsolt"  
> }  
> }  
> }

I get something like this

> {  
> "took" : 1,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 1,  
> "successful" : 1,  
> "skipped" : 0,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : {  
> "value" : 0,  
> "relation" : "eq"  
> },  
> "max\_score" : null,  
> "hits" :   
> }  
> }

I see in the index stats this -\> "index\_total": 179973,

So I dont know why I don't get any hits.

Edit: For some reason the indexes health are displayed as yellow (I don't know why is that)  
I have also restarted ES and Kibana, but I have still no hits.

Edit2: I think is adding all entries of the Mysql as one document under the same index, but I need each entry to be it's own.

What am I doing wrong?

Thank you

---

<div class="post-metadata">

**Author:** ![Gonzalo\_Garcia\_Roces](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gonzalo_garcia_roces/32/46713_2.png) [@Gonzalo\_Garcia\_Roces](https://discuss.elastic.co/u/Gonzalo_Garcia_Roces)\
**Post date:** [May 23, 2019, 2:59pm UTC](https://discuss.elastic.co/t/no-hits-after-indexing-mysql/182463/2 "2019-05-23T14:59:17Z")

</div>

I have found the problem for the Edit2, turns out i was addressing all entries with the same id so they were being overwritten all the time, and now I get hits.

I still don't know why the health is yellow

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [May 23, 2019, 3:03pm UTC](https://discuss.elastic.co/t/no-hits-after-indexing-mysql/182463/3 "2019-05-23T15:03:30Z")

</div>

> [@Gonzalo\_Garcia\_Roces](#):
>
> I still don't know why the health is yellow

If you are running on a single node but are configured to have replicas (which is on by default) then your health will always be yellow because the replicas cannot be assigned to a node.

---

<div class="post-metadata">

**Author:** ![Gonzalo\_Garcia\_Roces](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gonzalo_garcia_roces/32/46713_2.png) [@Gonzalo\_Garcia\_Roces](https://discuss.elastic.co/u/Gonzalo_Garcia_Roces)\
**Post date:** [May 23, 2019, 3:05pm UTC](https://discuss.elastic.co/t/no-hits-after-indexing-mysql/182463/4 "2019-05-23T15:05:06Z")

</div>

Yeah that will be the case, I'm just playing with this so far so I configured it with one node.

Thank you

---

<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:** [June 20, 2019, 3:05pm UTC](https://discuss.elastic.co/t/no-hits-after-indexing-mysql/182463/5 "2019-06-20T15:05:11Z")

</div>

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