Created
April 3, 2015 21:32
-
-
Save jprante/188c4fcfcd012d301b13 to your computer and use it in GitHub Desktop.
JDBC plugin with custom date/time format
This file contains hidden or 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
#!/bin/sh | |
/usr/local/mysql/bin/mysql -u root test <<EOT | |
drop table test; | |
create table test ( | |
id integer, | |
d text | |
); | |
insert into test values (1, '2015-04-03 00:45:00'); | |
EOT | |
curl -XDELETE 'localhost:9200/_river/my_test_river/' | |
curl -XDELETE 'localhost:9200/mytest' | |
curl -XPOST 'localhost:9200/_river/my_test_river/_meta' -d ' | |
{ | |
"type" : "jdbc", | |
"jdbc" : { | |
"url" : "jdbc:mysql://localhost:3306/test", | |
"user" : "", | |
"password" : "", | |
"sql" : "select *,id as _id from test", | |
"index" : "mytest", | |
"type" : "mydocs", | |
"index_settings" : { }, | |
"type_mapping" : { | |
"mydocs" : { | |
"properties" : { | |
"d" : { | |
"type" : "date", | |
"format" : "yyyy-MM-dd HH:mm:ss" | |
} | |
} | |
} | |
} | |
} | |
} | |
' | |
echo "sleeping while river should run..." | |
sleep 5 | |
curl -XGET 'localhost:9200/mytest/_mapping?pretty' | |
curl -XPOST 'localhost:9200/mytest/_search?pretty' -d ' | |
{ | |
"query": { | |
"match_all": { | |
} | |
} | |
}' | |
curl -XDELETE 'localhost:9200/_river/my_test_river/' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment