Hello Elasticsearch Community,
I am encountering an issue with importing data from MySQL to Elasticsearch using Logstash. Here’s the context and details:
Setup Information:
- MySQL Table Name:
criteria_sites
- Elasticsearch Index Name:
mysql-criterion-site-data
- Pipeline Input Configuration: I am using the JDBC plugin in Logstash to fetch data from MySQL.
MySQL Table Details:
- The table
criteria_sites
has 16,626 rows. - It has a composite primary key consisting of:
criterion_value_id
site_id
SHOW KEYS FROM criteria_sites WHERE Key_name = 'PRIMARY';
+----------------+------------+----------+--------------+--------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression |
+----------------+------------+----------+--------------+--------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
| criteria_sites | 0 | PRIMARY | 1 | criterion_value_id | A | 14030 | NULL | NULL | | BTREE | | | YES | NULL |
| criteria_sites | 0 | PRIMARY | 2 | site_id | A | 16626 | NULL | NULL | | BTREE | | | YES | NULL |
+----------------+------------+----------+--------------+--------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
Elasticsearch Output Configuration in Logstash:
output {
elasticsearch {
hosts => ["http://ip-address:9200"]
index => "mysql-criterion-site-data"
document_id => "criterion-site-%{criterion_value_id}" # Uses only `criterion_value_id` as the ID
}
}
Issue:
When I import the table using Logstash, the document count in Elasticsearch doesn’t match the number of rows in the MySQL table.
- MySQL Table Rows: 16,626
- Elasticsearch Index Statistics:
yellow open mysql-criterion-site-data FSkeQzvVQKa4PwIDbnYV0Q 1 1 14030 2596 1.3mb