Skip to content

Transform nodes

Transform nodes allow you to change the output of the document type

rename

We can simply define this JSON schema.

[
    {
        "database": "book",
        "index": "book",
        "nodes": {
            "table": "book",
            "columns": [
                "isbn",
                "title"
            ],
            "transform": {
                "rename": {
                    "isbn": "book_isbn",
                    "title": "book_title"
                }
            }
        }
    }
]

To get this document structure in Elasticsearch

[
    {
        "book_isbn": "9785811243570",
        "book_title": "Charlie and the chocolate factory"
    },
    {
        "book_isbn": "9788374950978",
        "book_title": "Kafka on the Shore"
    },
    {
        "book_isbn": "9781471331435",
        "book_title": "1984"
    }
]

mapping

You can specify the data type for an Elasticsearch field in the schema.

You can find the list of supported data types here

[
    {
        "database": "book",
        "index": "book",
        "node": {
            "table": "book",
            "columns": [
                "isbn",
                "title"
            ],
            "transform": {
                "mapping": {
                    "isbn": "long",
                    "title": "keyword"
                }
            }
        }
    }
]

concat

You can concatenate multiple columns into a single field with an optional delimiter.

[
    {
        "database": "book",
        "index": "book",
        "node": {
            "table": "book",
            "columns": [
                "title",
                "firstname",
                "lastname"
            ],
            "transform": {
                "concat": {
                    "columns": ["title", "firstname", "lastname"],
                    "destination": "fullname",
                    "delimiter": "-"
                }
            }
        }
    }
]