{"id":16323332,"url":"https://github.com/yzevm/sync-postgresql-with-elasticsearch-example","last_synced_at":"2025-09-07T07:10:29.705Z","repository":{"id":170420331,"uuid":"176280944","full_name":"yzevm/sync-postgresql-with-elasticsearch-example","owner":"yzevm","description":"🔄  Sync PostgreSQL to Elasticsearch via Debezium","archived":false,"fork":false,"pushed_at":"2020-09-13T08:08:16.000Z","size":12,"stargazers_count":98,"open_issues_count":3,"forks_count":22,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-08-31T05:55:44.941Z","etag":null,"topics":["debezium","elasticsearch","example","master-slave","postgresql","real-time","replication","sync","sync-postgresql"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yzevm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-18T12:32:48.000Z","updated_at":"2025-01-08T11:23:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"06f5667e-05a1-4636-a4da-80166edea489","html_url":"https://github.com/yzevm/sync-postgresql-with-elasticsearch-example","commit_stats":null,"previous_names":["yzevm/sync-postgresql-with-elasticsearch-example"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yzevm/sync-postgresql-with-elasticsearch-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yzevm%2Fsync-postgresql-with-elasticsearch-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yzevm%2Fsync-postgresql-with-elasticsearch-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yzevm%2Fsync-postgresql-with-elasticsearch-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yzevm%2Fsync-postgresql-with-elasticsearch-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yzevm","download_url":"https://codeload.github.com/yzevm/sync-postgresql-with-elasticsearch-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yzevm%2Fsync-postgresql-with-elasticsearch-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274006235,"owners_count":25206104,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["debezium","elasticsearch","example","master-slave","postgresql","real-time","replication","sync","sync-postgresql"],"created_at":"2024-10-10T22:54:36.691Z","updated_at":"2025-09-07T07:10:29.676Z","avatar_url":"https://github.com/yzevm.png","language":"Dockerfile","readme":"# Sync PostgreSQL with Elasticsearch via Debezium\n\n### Schema\n\n```\n                   +-------------+\n                   |             |\n                   |  PostgreSQL |\n                   |             |\n                   +------+------+\n                          |\n                          |\n                          |\n          +---------------v------------------+\n          |                                  |\n          |           Kafka Connect          |\n          |    (Debezium, ES connectors)     |\n          |                                  |\n          +---------------+------------------+\n                          |\n                          |\n                          |\n                          |\n                  +-------v--------+\n                  |                |\n                  | Elasticsearch  |\n                  |                |\n                  +----------------+\n\n\n```\nWe are using Docker Compose to deploy the following components:\n\n* PostgreSQL\n* Kafka\n  * ZooKeeper\n  * Kafka Broker\n  * Kafka Connect with [Debezium](http://debezium.io/) and [Elasticsearch](https://github.com/confluentinc/kafka-connect-elasticsearch) Connectors\n* Elasticsearch\n\n### Usage\n\n```shell\ndocker-compose up --build\n\n# wait until it's setup\n./start.sh\n```\n\n### Testing\n\nCheck database's content\n\n```shell\n# Check contents of the PostgreSQL database:\ndocker-compose exec postgres bash -c 'psql -U $POSTGRES_USER $POSTGRES_DATABASE -c \"SELECT * FROM users\"'\n\n# Check contents of the Elasticsearch database:\ncurl http://localhost:9200/users/_search?pretty\n```\n\nCreate user\n\n```shell\ndocker-compose exec postgres bash -c 'psql -U $POSTGRES_USER $POSTGRES_DATABASE'\ntest_db=# INSERT INTO users (email) VALUES ('apple@gmail.com');\n\n# Check contents of the Elasticsearch database:\ncurl http://localhost:9200/users/_search?q=id:6\n```\n\n```json\n{\n  ...\n  \"hits\": {\n    \"total\": 1,\n    \"max_score\": 1.0,\n    \"hits\": [\n      {\n        \"_index\": \"users\",\n        \"_type\": \"_doc\",\n        \"_id\": \"6\",\n        \"_score\": 1.0,\n        \"_source\": {\n          \"id\": 6,\n          \"email\": \"apple@gmail.com\"\n        }\n      }\n    ]\n  }\n}\n```\n\nUpdate user\n\n```shell\ntest_db=# UPDATE users SET email = 'tesla@gmail.com' WHERE id = 6;\n\n# Check contents of the Elasticsearch database:\ncurl http://localhost:9200/users/_search?q=id:6\n```\n\n```json\n{\n  ...\n  \"hits\": {\n    \"total\": 1,\n    \"max_score\": 1.0,\n    \"hits\": [\n      {\n        \"_index\": \"users\",\n        \"_type\": \"_doc\",\n        \"_id\": \"6\",\n        \"_score\": 1.0,\n        \"_source\": {\n          \"id\": 6,\n          \"email\": \"tesla@gmail.com\"\n        }\n      }\n    ]\n  }\n}\n```\n\nDelete user\n\n```shell\ntest_db=# DELETE FROM users WHERE id = 6;\n\n# Check contents of the Elasticsearch database:\ncurl http://localhost:9200/users/_search?q=id:6\n```\n\n```json\n{\n  ...\n  \"hits\": {\n    \"total\": 1,\n    \"max_score\": 1.0,\n    \"hits\": []\n  }\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyzevm%2Fsync-postgresql-with-elasticsearch-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyzevm%2Fsync-postgresql-with-elasticsearch-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyzevm%2Fsync-postgresql-with-elasticsearch-example/lists"}