-
-
Save nkabir/9083604 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"type": "jdbc", | |
"jdbc": { | |
// provide connection parameters for your JDBC | |
"driver": "com.mysql.jdbc.Driver", | |
"url": "jdbc:mysql://localhost:3306/yourDb", | |
"user": "login", | |
"password": "pass", | |
// define stragety to load your data (simple strategy makes periodical polls from JDBC) | |
"strategy": "simple", | |
"poll": "1m", | |
// and finally define SQL query. 1. define _id to avoid duplicates during poll. 2. you can define aliases for all the columns, so ElasticSearch do not contains database names (if you want to...) | |
"sql": "select id as _id, product as yourProduct, my_price as myPrice, date_created as dateCreated * from transaction WHERE user_id=1 and deleted = 0" | |
}, | |
"index": { | |
// define index name (index is kind of database when you compare it with relation databases) | |
"index": "index_name", | |
// define type name (type is kind of database table when you compare it with relation databases) | |
"type": "index_type", | |
// you can define batch paramets that will be used for fetching data from JDBC | |
"bulk_size": 5000, | |
"max_bulk_requests": 30, | |
// type mapping is optional, but if you need to 'not_analyzed' for your strings, you have to do it | |
"type_mapping": "{\"index_name\" : {\"properties\" : {\"_id\":{\"type\":\"long\",\"store\":\"yes\"},\"yourProduct\":{\"type\":\"string\",\"store\":\"yes\",\"index\":\"not_analyzed\"},\"myPrice\":{\"type\":\"double\",\"store\":\"yes\"},\"dateCreated\":{\"type\":\"date\",\"format\":\"date_optional_time\",\"store\":\"yes\"}}}}", | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment