# Data showing wrong when searched

**URL:** <https://discuss.elastic.co/t/data-showing-wrong-when-searched/98934>\
**Category:** Elasticsearch\
**Created:** [August 31, 2017, 5:16am UTC](https://discuss.elastic.co/t/data-showing-wrong-when-searched/98934 "2017-08-31T05:16:59Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![vaibhav2903](https://avatars.discourse-cdn.com/v4/letter/v/a9a28c/32.png) [@vaibhav2903](https://discuss.elastic.co/u/vaibhav2903)\
**Post date:** [August 31, 2017, 5:16am UTC](https://discuss.elastic.co/t/data-showing-wrong-when-searched/98934/1 "2017-08-31T05:16:59Z")

</div>

Hi! i have a dataset of more than 10 lac rows. I have integrated elasticsearch with Mysql using logstash.  
When i type the following URL to fetch in postman,  
[http://localhost:9200/persondetails/Document/\_search?q=\*](http://localhost:9200/persondetails/Document/_search?q=*)  
i get the following,  
{  
"took": 169,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
**"total": 1,**  
"max\_score": 1,  
"hits": [  
{  
"\_index": "persondetails",  
"\_type": "Document",  
"\_id": "%{idDocument}",  
"\_score": 1,  
"\_source": {  
"iddocument": 151170,  
"@timestamp": "2017-08-31T05:03:43.968Z",  
"author": "rishav",  
"expiry\_date": "2014-09-24T18:30:00.000Z",  
"@version": "1",  
"description": "d help ",  
"creation\_date": "2014-05-24T18:30:00.000Z",  
"type": 10  
}  
}  
]  
}  
}  
it is wrong as the number of rows in my table are more than 10 lac and this shows that total is only 1. I am unable to find what is the mistake here.

---

<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:** [August 31, 2017, 5:19am UTC](https://discuss.elastic.co/t/data-showing-wrong-when-searched/98934/2 "2017-08-31T05:19:17Z")

</div>

What does `_cat/indices?v` show?

---

<div class="post-metadata">

**Author:** ![vaibhav2903](https://avatars.discourse-cdn.com/v4/letter/v/a9a28c/32.png) [@vaibhav2903](https://discuss.elastic.co/u/vaibhav2903)\
**Post date:** [August 31, 2017, 5:22am UTC](https://discuss.elastic.co/t/data-showing-wrong-when-searched/98934/3 "2017-08-31T05:22:59Z")

</div>

it shows this message

health |status| index | uuid | pri |rep |docs.count |docs.deleted |store.size |pri.store.size  
yellow| open | persondetails |4FiGngZcQfS0Xvu6IeHIfg |5 | 1 | 2 | 1054 | 488.2kb | 488.2kb

---

<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:** [August 31, 2017, 5:57am UTC](https://discuss.elastic.co/t/data-showing-wrong-when-searched/98934/4 "2017-08-31T05:57:32Z")

</div>

Looks like you have 2 documents, and 1054 deleted ones.

What does your Logstash config look like?

---

<div class="post-metadata">

**Author:** ![vaibhav2903](https://avatars.discourse-cdn.com/v4/letter/v/a9a28c/32.png) [@vaibhav2903](https://discuss.elastic.co/u/vaibhav2903)\
**Post date:** [August 31, 2017, 6:31am UTC](https://discuss.elastic.co/t/data-showing-wrong-when-searched/98934/5 "2017-08-31T06:31:11Z")

</div>

This is my logstash.conf file  
input {  
jdbc {  
jdbc\_connection\_string =\> "jdbc:mysql://127.0.0.1:3306/persondetails"  
jdbc\_user =\> "root"  
jdbc\_password =\> ""  
schedule =\> "\* \* \* \* \*"  
jdbc\_validate\_connection =\> true  
jdbc\_driver\_library =\> "/usr/local/Cellar/logstash/5.5.2/mysql-connector-java-3.1.14/mysql-connector-java-3.1.14-bin.jar"  
jdbc\_driver\_class =\> "com.mysql.jdbc.Driver"  
statement =\> "SELECT \* FROM Document"  
type =\> "persondetails"  
}  
}  
output {  
elasticsearch {  
#protocol=\>http  
index =\>"persondetails"  
document\_type =\> "Document"  
document\_id =\> "%{idDocument}"  
hosts =\> ["[http://localhost:9200](http://localhost:9200)"]  
stdout{ codec =\> json\_lines}  
}  
}

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [August 31, 2017, 6:51am UTC](https://discuss.elastic.co/t/data-showing-wrong-when-searched/98934/6 "2017-08-31T06:51:28Z")

</div>

> [@vaibhav2903](#):
>
> "\_id": “%{idDocument}”,

> [@vaibhav2903](#):
>
> “iddocument”: 151170,

It looks like the field you have assigned as document id is incorrectly spelled (it is case sensitive and you have a capital D in the output but not the document), and that the string `%{idDocument}` has been used as id, causing the same document to be updated over and over.

---

<div class="post-metadata">

**Author:** ![vaibhav2903](https://avatars.discourse-cdn.com/v4/letter/v/a9a28c/32.png) [@vaibhav2903](https://discuss.elastic.co/u/vaibhav2903)\
**Post date:** [August 31, 2017, 7:22am UTC](https://discuss.elastic.co/t/data-showing-wrong-when-searched/98934/7 "2017-08-31T07:22:22Z")

</div>

I have used idDocument in my mySql table as my row name. So, where should i change the name from iddocument to idDocument? I have written %{idDocument} as well in my conf file.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [August 31, 2017, 7:25am UTC](https://discuss.elastic.co/t/data-showing-wrong-when-searched/98934/8 "2017-08-31T07:25:54Z")

</div>

Based on the sample document you posted, all field names are lowercased (might be done by the JDBC input?), so your config need to match that. While developing config, send data to a `stdout` output plugin with a `rubydebug` codec, as this makes it easy to see the actual structure of events and debug without having to go to Elasticsearch in the process.

---

<div class="post-metadata">

**Author:** ![vaibhav2903](https://avatars.discourse-cdn.com/v4/letter/v/a9a28c/32.png) [@vaibhav2903](https://discuss.elastic.co/u/vaibhav2903)\
**Post date:** [August 31, 2017, 7:43am UTC](https://discuss.elastic.co/t/data-showing-wrong-when-searched/98934/9 "2017-08-31T07:43:38Z")

</div>

Problem has been resolved. Thanks for helping me out! i changed it to iddocument and it worked.

---

<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:** [September 28, 2017, 7:43am UTC](https://discuss.elastic.co/t/data-showing-wrong-when-searched/98934/10 "2017-09-28T07:43:42Z")

</div>

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