Skip to content

165: Include dataset for ElasticSearch - #177

Open
thanglequoc wants to merge 32 commits into
masterfrom
165_IncludeDataForElasticSearch
Open

165: Include dataset for ElasticSearch#177
thanglequoc wants to merge 32 commits into
masterfrom
165_IncludeDataForElasticSearch

Conversation

@thanglequoc

Copy link
Copy Markdown
Owner
  • Include dataset for ElasticSearch
  • Because ElasticSearch requires strict GIS data validation, and the existing GIS data imported from the upstream have some corruption (check via Postgis ST_IsValid), so we need to correct the GIS data
  • Include post geometry correction with Postgis ST_CollectionExtract(ST_MakeValid(ST_GeomFromText(geom_wkt, 4326)), 3)
  • Update test
  • Update main script, add post geometry fix to the main execution path
  • Data change verified with pre-post GIS data comparison, report provided in development/corrupted_gis_ward_data/gis_comparison_report_2026-07-24.md

- Spec: docs/superpowers/specs/2026-07-18-elasticsearch-dataset-export-design.md
- Plan: docs/superpowers/plans/2026-07-18-elasticsearch-dataset-export.md
- Branch: 165_IncludeDataForElasticSearch

Design covers:
- Two ES indices: provinces (no GIS) and provinces-gis (with GIS)
- Denormalized province documents with embedded nested wards
- SearchKeywords array (code, codeName, tone-stripped name, nameEn)
- Embedded AdministrativeUnit object
- Bulk API-compatible NDJSON output
- Static mapping files for both indices
- Meta field (no underscore prefix - ES reserves _-prefixed fields)
- Add Elasticsearch DTOs (ElasticsearchProvinceDocument, ElasticsearchWardDocument,
  ElasticsearchAdministrativeUnit, ElasticsearchGIS, ElasticsearchMeta)
- Add GenerateSearchKeywords() with Viet tone mark removal and deduplication
- Add ConvertToElasticsearchProvinceModel() mapper with embedded wards and AdminUnit
- Create ElasticsearchDatasetFileWriter with WriteToFile() for non-GIS index
  and WriteElasticsearchGISDataToFile() for provinces-gis GIS index
- Generate Bulk API-compatible NDJSON (index action + document lines)
- Generate static index mappings (provinces.json, provinces-gis.json)
- Generate dataset README with curl import examples and query samples
- Add unit tests for writer, NDJSON format, parseBBox, and SearchKeywords
- Wire ES writer into ReadAndGenerateSQLDatasets() and GenerateGISSQLDatasets()
- Create top-level elasticsearch/README.md with user documentation

Output: elasticsearch/{provinces.ndjson, provinces-gis.ndjson,
- Add Elasticsearch DTOs (ElasticsearchProvinceDocument, Elasxisting)
- Include post geometry correction with Postgis ST_CollectionExtract(ST_MakeValid(ST_GeomFromText(geom_wkt, 4326)), 3)
- Update test
- Update main script, add post geometry fix to the main execution path
- Data change verified with pre-post GIS data comparison, report provided in development/corrupted_gis_ward_data/gis_comparison_report_2026-07-24.md
@thanglequoc thanglequoc self-assigned this Jul 25, 2026
…ql/, sqlserver/, oracle/) matching root layout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant