# Beginner question: Skipping the filtering of id into \[@metadata\]\[\_id\]

**URL:** <https://discuss.elastic.co/t/beginner-question-skipping-the-filtering-of-id-into-metadata-id/254508>\
**Category:** Logstash\
**Created:** [November 6, 2020, 9:16am UTC](https://discuss.elastic.co/t/beginner-question-skipping-the-filtering-of-id-into-metadata-id/254508 "2020-11-06T09:16:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pyrovoice](https://avatars.discourse-cdn.com/v4/letter/p/b5ac83/32.png) [@pyrovoice](https://discuss.elastic.co/u/pyrovoice)\
**Post date:** [November 6, 2020, 9:16am UTC](https://discuss.elastic.co/t/beginner-question-skipping-the-filtering-of-id-into-metadata-id/254508/1 "2020-11-06T09:16:53Z")

</div>

I followed the following tutorial: [https://www.elastic.co/blog/how-to-keep-elasticsearch-synchronized-with-a-relational-database-using-logstash](https://www.elastic.co/blog/how-to-keep-elasticsearch-synchronized-with-a-relational-database-using-logstash)

The configuration file for the pipeline contains the following:

```auto
    input {
      jdbc {
        jdbc_driver_library => "<path>/mysql-connector-java-8.0.16.jar"
        jdbc_driver_class => "com.mysql.jdbc.Driver"
        jdbc_connection_string => "jdbc:mysql://<MySQL host>:3306/es_db"
        jdbc_user => <my username>
        jdbc_password => <my password>
        jdbc_paging_enabled => true
        tracking_column => "unix_ts_in_secs"
        use_column_value => true
        tracking_column_type => "numeric"
        schedule => "*/5 * * * * *"
        statement => "SELECT *, UNIX_TIMESTAMP(modification_time) AS unix_ts_in_secs FROM es_table WHERE (UNIX_TIMESTAMP(modification_time) > :sql_last_value AND modification_time < NOW()) ORDER BY modification_time ASC"
      }
    }
    filter {
      mutate {
        copy => { "id" => "[@metadata][_id]"}
        remove_field => ["id", "@version", "unix_ts_in_secs"]
      }
    }
    output {
      # stdout { codec => "rubydebug"}
      elasticsearch {
          index => "rdbms_sync_idx"
          document_id => "%{[@metadata][_id]}"
      }
    }

```

Specifically for the filter. If I got this right, we want each database entry to have a unique document\_id so that the data will be correctly updated.

- Does passing the data to metadata.\_id achieves anything? We simply pass this data again to document\_id in the output, so why not passing the ID directly?
- In tables with multiple primary keys, it is not possible to have a single ID table. My solution was to add all columns forming the primary key into document\_id ( **document\_id =\> "%{col1}%{col2}..."** ) Is this the correct approach? The data seems to get updated correctly

Thank you for your help.

---

<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:** [December 4, 2020, 9:16am UTC](https://discuss.elastic.co/t/beginner-question-skipping-the-filtering-of-id-into-metadata-id/254508/2 "2020-12-04T09:16:55Z")

</div>

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