elasticsearch-jdbc mysql导入时typemapping无法识别,请帮忙解决
Elasticsearch | 作者 jason1 | 发布于2015年12月09日 | 阅读数:5833
elasticsearch-jdbc mysql,多条SQL对应多个type,并且在一个index下,在导入时候只有type product有效,剩余product1、product2、product3、product4都是无效的,请帮忙看看怎么解决,
#!/bin/sh
export JDBC_IMPORTER_HOME=${HOME}/search/elasticsearch-jdbc-2.0.0.0
bin=$JDBC_IMPORTER_HOME/bin
lib=$JDBC_IMPORTER_HOME/lib
echo '
{
"type" : "jdbc",
"jdbc" : {
"url" : "jdbc:mysql://192.168.1.1:3306/test",
"driver": "com.mysql.jdbc.Driver",
"user" : "root",
"password" : "111111",
"locale" : "en_US",
"sql" :[ "SELECT product.id as _id,\"myindex_v1\" as _index, \"product\" as _type, product.id, ",
"SELECT t.id AS _id,\"myindex_v1\" as _index, \"product1\" AS _type, t.id AS \"id\", " ,
"SELECT brand.id AS _id,\"myindex_v1\" as _index, \"product2\" AS _type, brand.id AS \"id\", " ,
"SELECT \"myindex_v1\" AS _index, \"product3\" AS _type, CONCAT(vin.vin_f, vin.vin_e) AS _id,",
"SELECT \"myindex_v1\" AS _index, \"product4\" AS _type, model.id AS _id, model.id AS \"modelId\", "
] ,
"elasticsearch" : {
"cluster" : "elasticsearch",
"host" : "192.168.1.1:9300"
},
"index" :"myindex_v1",
"type" : "product",
"max_bulk_actions" : 20000,
"index_settings" : {
"index" : {
"number_of_shards" : 3
}
},
"type_mapping": {
"product": {
"_all": {
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word",
"term_vector": "no",
"store": "false"
},
"properties": {
"code": {
"type": "string",
"index" : "not_analyzed"
},
"explainImg": {
"type": "string",
"index" : "not_analyzed"
}
},
"productBrand": {
"properties": {
"id": {
"type": "long"
},
"logo": {
"type": "string",
"index" : "not_analyzed"
}
}
},
"productPicture": {
"properties": {
"bigImg": {
"type": "string",
"index" : "not_analyzed"
}
}
},
"productProvider": {
"properties": {
"code": {
"type": "string",
"index" : "not_analyzed"
}
}
},
"productText": {
"properties": {
"description": {
"type": "string",
"index" : "not_analyzed"
},
"productId": {
"type": "long"
}
}
}
}
},
"product1": {
"properties": {
"brandId": {
"type": "long"
},
"clrIn": {
"type": "string",
"index" : "not_analyzed"
},
"endTime": {
"type": "string",
"index" : "not_analyzed"
},
"id": {
"type": "long"
}
}
},
"product2": {
"properties": {
"id": {
"type": "long"
}
}
},
"product3": {
"properties": {
"clrIn": {
"type": "string",
"index" : "not_analyzed"
}
}
},
"product4": {
"_all": {
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word",
"term_vector": "no",
"store": "false"
},
"properties": {
"carBrandId": {
"type": "long"
}
}
}
},
"metrics" : {
"enabled" : true
}
}
}
' | java \
-cp "${lib}/*" \
-Dlog4j.configurationFile=${bin}/log4j2.xml \
org.xbib.tools.Runner \
org.xbib.tools.JDBCImporter
#!/bin/sh
export JDBC_IMPORTER_HOME=${HOME}/search/elasticsearch-jdbc-2.0.0.0
bin=$JDBC_IMPORTER_HOME/bin
lib=$JDBC_IMPORTER_HOME/lib
echo '
{
"type" : "jdbc",
"jdbc" : {
"url" : "jdbc:mysql://192.168.1.1:3306/test",
"driver": "com.mysql.jdbc.Driver",
"user" : "root",
"password" : "111111",
"locale" : "en_US",
"sql" :[ "SELECT product.id as _id,\"myindex_v1\" as _index, \"product\" as _type, product.id, ",
"SELECT t.id AS _id,\"myindex_v1\" as _index, \"product1\" AS _type, t.id AS \"id\", " ,
"SELECT brand.id AS _id,\"myindex_v1\" as _index, \"product2\" AS _type, brand.id AS \"id\", " ,
"SELECT \"myindex_v1\" AS _index, \"product3\" AS _type, CONCAT(vin.vin_f, vin.vin_e) AS _id,",
"SELECT \"myindex_v1\" AS _index, \"product4\" AS _type, model.id AS _id, model.id AS \"modelId\", "
] ,
"elasticsearch" : {
"cluster" : "elasticsearch",
"host" : "192.168.1.1:9300"
},
"index" :"myindex_v1",
"type" : "product",
"max_bulk_actions" : 20000,
"index_settings" : {
"index" : {
"number_of_shards" : 3
}
},
"type_mapping": {
"product": {
"_all": {
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word",
"term_vector": "no",
"store": "false"
},
"properties": {
"code": {
"type": "string",
"index" : "not_analyzed"
},
"explainImg": {
"type": "string",
"index" : "not_analyzed"
}
},
"productBrand": {
"properties": {
"id": {
"type": "long"
},
"logo": {
"type": "string",
"index" : "not_analyzed"
}
}
},
"productPicture": {
"properties": {
"bigImg": {
"type": "string",
"index" : "not_analyzed"
}
}
},
"productProvider": {
"properties": {
"code": {
"type": "string",
"index" : "not_analyzed"
}
}
},
"productText": {
"properties": {
"description": {
"type": "string",
"index" : "not_analyzed"
},
"productId": {
"type": "long"
}
}
}
}
},
"product1": {
"properties": {
"brandId": {
"type": "long"
},
"clrIn": {
"type": "string",
"index" : "not_analyzed"
},
"endTime": {
"type": "string",
"index" : "not_analyzed"
},
"id": {
"type": "long"
}
}
},
"product2": {
"properties": {
"id": {
"type": "long"
}
}
},
"product3": {
"properties": {
"clrIn": {
"type": "string",
"index" : "not_analyzed"
}
}
},
"product4": {
"_all": {
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word",
"term_vector": "no",
"store": "false"
},
"properties": {
"carBrandId": {
"type": "long"
}
}
}
},
"metrics" : {
"enabled" : true
}
}
}
' | java \
-cp "${lib}/*" \
-Dlog4j.configurationFile=${bin}/log4j2.xml \
org.xbib.tools.Runner \
org.xbib.tools.JDBCImporter
0 个回复