# How to synchronize with oracle when data updated?

**URL:** <https://discuss.elastic.co/t/how-to-synchronize-with-oracle-when-data-updated/69381>\
**Category:** Logstash\
**Created:** [December 19, 2016, 3:14am UTC](https://discuss.elastic.co/t/how-to-synchronize-with-oracle-when-data-updated/69381 "2016-12-19T03:14:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tao\_Zhang](https://avatars.discourse-cdn.com/v4/letter/t/838e76/32.png) [@Tao\_Zhang](https://discuss.elastic.co/u/Tao_Zhang)\
**Post date:** [December 19, 2016, 3:14am UTC](https://discuss.elastic.co/t/how-to-synchronize-with-oracle-when-data-updated/69381/1 "2016-12-19T03:14:38Z")

</div>

I'm trying to synchronize oracle to Elasticsearch by logstash-input-jdbc .But I failed.  
Could you tell me how to do it?

> Env:  
> windows 7 64bit (※Japanese)  
> oracleDB 11g  
> Elasticsearch 5.1.1  
> Logstash 5.1.1

```
Ex: syntest.conf
input {  
  jdbc {
    jdbc_driver_library => "ojdbc6.jar"
    jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver"
    jdbc_connection_string => "jdbc:oracle:thin:@//localhost:1521/XE"
    jdbc_user => userid
    jdbc_password => userpass
    schedule => "*/2 * * * *"
    statement => "select * from TEST where TEST.modified > :sql_last_value"
    last_run_metadata_path => "./barbar.dat"
  }
} 

output { 
  elasticsearch { 
    hosts => ["localhost:9200"] 
    index => "test"
    document_type => "TEST"
    document_id => "%{id}"
  } 
}

Ex: TEST table
id,name,modified
1111,testdata,2016/12/20 20:28:08

Ex: SQL
update TEST set MODIFIED = TO_DATE('2016/12/21 20:28:08','yyyy/mm/dd hh24:mi:ss') where id > 1000;
update TEST set name = 'testdata02' where id = '1111';

```

* * *

The result in below show logstash runed successfully but ES's result is old.

> ```
> {
> "_index" : "test",
> "_type" : "TEST",
> "_id" : "1111",
> "_score" : 0.826844,
> "_source" : {
> "tags" : [],
> "@timestamp" : "2016-12-19T02:50:00.278Z",
> "classname" : null,
> "name" : "testdata",
> "@version" : "1",
> "modified" : "2016-12-17T11:28:08.000Z",
> "id" : 1111,
> }
> 
> ```

Could you tell me how to synchronize ?  
And is it possible to check the version of ES's data. (Does @version 's value will change when data updated? )

---

<div class="post-metadata">

**Author:** ![Tao\_Zhang](https://avatars.discourse-cdn.com/v4/letter/t/838e76/32.png) [@Tao\_Zhang](https://discuss.elastic.co/u/Tao_Zhang)\
**Post date:** [December 19, 2016, 5:38am UTC](https://discuss.elastic.co/t/how-to-synchronize-with-oracle-when-data-updated/69381/2 "2016-12-19T05:38:10Z")

</div>

I find I can synchronize data with same config. Maybe just my env had some problem.

So my remaining question is fellowing:  
Is it possible to check the version of ES's data. (Does @version 's value will change when data updated? )

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [December 19, 2016, 6:48am UTC](https://discuss.elastic.co/t/how-to-synchronize-with-oracle-when-data-updated/69381/3 "2016-12-19T06:48:56Z")

</div>

> Is it possible to check the version of ES's data.

What do you mean?

> Does @version 's value will change when data updated?

No, `@version` is the version of Logstash's event schema. Elasticsearch documents have a `_version` metadata field that increments by one for each update, but I don't see how you could use that here.

---

<div class="post-metadata">

**Author:** ![Tao\_Zhang](https://avatars.discourse-cdn.com/v4/letter/t/838e76/32.png) [@Tao\_Zhang](https://discuss.elastic.co/u/Tao_Zhang)\
**Post date:** [December 20, 2016, 9:38am UTC](https://discuss.elastic.co/t/how-to-synchronize-with-oracle-when-data-updated/69381/4 "2016-12-20T09:38:03Z")

</div>

Thank you very much.

```
> Is it possible to check the version of ES's data.
What do you mean?

```

I mean is there a fieｌd which incremented when data updated. If there is ,I think I can see it to check update worked successfully or not.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [December 20, 2016, 10:09am UTC](https://discuss.elastic.co/t/how-to-synchronize-with-oracle-when-data-updated/69381/5 "2016-12-20T10:09:29Z")

</div>

Yes, the `_version` field is incremented each time the documented is updated.

---

<div class="post-metadata">

**Author:** ![Tao\_Zhang](https://avatars.discourse-cdn.com/v4/letter/t/838e76/32.png) [@Tao\_Zhang](https://discuss.elastic.co/u/Tao_Zhang)\
**Post date:** [December 21, 2016, 12:48am UTC](https://discuss.elastic.co/t/how-to-synchronize-with-oracle-when-data-updated/69381/6 "2016-12-21T00:48:05Z")

</div>

Thank you very much. It's clear.

---

<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:** [January 18, 2017, 12:48am UTC](https://discuss.elastic.co/t/how-to-synchronize-with-oracle-when-data-updated/69381/7 "2017-01-18T00:48:09Z")

</div>

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