# ElasticSearch index is not updating correctly

**URL:** <https://discuss.elastic.co/t/elasticsearch-index-is-not-updating-correctly/188222>\
**Category:** Elasticsearch\
**Created:** [July 1, 2019, 4:17am UTC](https://discuss.elastic.co/t/elasticsearch-index-is-not-updating-correctly/188222 "2019-07-01T04:17:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![avinash9999](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/avinash9999/32/91409_2.png) [@avinash9999](https://discuss.elastic.co/u/avinash9999)\
**Post date:** [July 1, 2019, 4:17am UTC](https://discuss.elastic.co/t/elasticsearch-index-is-not-updating-correctly/188222/1 "2019-07-01T04:17:16Z")

</div>

I have a logstash code for updating elasticsearch index in every 5 minutes from my SQL server.  
I am using action update to do this.

> action =\> 'update'  
> There is a problem that my index is not updating with every records.  
> Few records and not getting updated.

```
 I am also using this same index in my python code for other tasks.
 Is it possible it can't update and search at same time causing miss-match in index data.??

```

Thanks in advance

---

<div class="post-metadata">

**Author:** ![yaauie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yaauie/32/23363_2.png) [@yaauie](https://discuss.elastic.co/u/yaauie)\
**Post date:** [July 1, 2019, 8:00am UTC](https://discuss.elastic.co/t/elasticsearch-index-is-not-updating-correctly/188222/2 "2019-07-01T08:00:57Z")

</div>

how is your jdbc input configured? By default, it attempts to select only _new_ documents (see docs on [`sql_last_value`](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html#_predefined_parameters)).

---

<div class="post-metadata">

**Author:** ![avinash9999](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/avinash9999/32/91409_2.png) [@avinash9999](https://discuss.elastic.co/u/avinash9999)\
**Post date:** [July 1, 2019, 8:22am UTC](https://discuss.elastic.co/t/elasticsearch-index-is-not-updating-correctly/188222/3 "2019-07-01T08:22:03Z")

</div>

This is my jdbc input

> jdbc {  
> jdbc\_connection\_string =\> "xxxxxxx"  
> jdbc\_user =\> "xxxxx"  
> jdbc\_password =\> "xxxxxxx"  
> jdbc\_driver\_library =\> "C:/sqljdbc\_4.2/enu/jre8/sqljdbc42.jar"  
> jdbc\_driver\_class =\> "com.microsoft.sqlserver.jdbc.SQLServerDriver"  
> statement =\> "select  
> s.SurveyId,  
> s.LanguageId,  
> s.clientid,  
> s.SurveyStatusId,s.FirstCompleteDate  
> from  
> Surveys s (nolock)  
> where s.AccountId=1 and s.UpdateTimestamp \> dateadd(hh,-4,:sql\_last\_value)"  
> last\_run\_metadata\_path =\> "D:/Elasticsearch/logstashSurveys/logstash\_last\_run/sc-surveys.logstash\_jdbc\_last\_run"  
> schedule =\> "\*/20 \* \* \* \* \*"  
> }

And This is my elasticsearch output

> ```
> elasticsearch { 
> hosts => ["xxxx"]
> user => "xxx"
> password => "xxxx" 
> index => "sc-surveys"
> document_id => "%{surveyid}"
> action => 'update'
> doc_as_upsert => "true"
> }
> 
> ```

---

<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 29, 2019, 8:22am UTC](https://discuss.elastic.co/t/elasticsearch-index-is-not-updating-correctly/188222/4 "2019-07-29T08:22:11Z")

</div>

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