每次后台去运行.sh文件运行一次ES中就会把之前的数据重复一次,并不是覆盖,自己看了一下应该是时间戳的问题,因为.sh里"schedule" 字段是格式化的时间,而我的数据库里存的是时间戳的.
#bin/sh
bin=$JDBC_IMPORTER_HOME/bin
lib=$JDBC_IMPORTER_HOME/lib
echo '
{
"type" : "jdbc",
"jdbc" : {
"url" : "jdbc:mysql://localhost:3306/wenda",
"user" : "root",
"password" : "123456",
"statefile" : "statefile-ask.json",
"schedule" : "0 0-59 0-23 ? * *", #应该是这里的问题
"sql" : [
{
"statement" : "select * from think_ask where create_time > ?",
"parameter" : [ "$metrics.lastexecutionstart" ]
}
],
"index" : "myindex",
"type" : "mytype",
"index_settings" : {
"analysis" : {
"analyzer" : {
"ik" : {
"tokenizer" : "ik"
}
}
}
},
"type_mapping": {
"ask" : {
"properties" : {
"asid" : {
"type" : "long"
},
"content" : {
"type" : "string",
"analyzer" : "ik",
"index" : "not_analyzed",
"searchAnalyzer": "pinyin_analyzer"
},
"uname" : {
"type" : "string",
"analyzer" : "ik"
},
"click_count" : {
"type" : "long"
},
"time" : {
"type" : "long"
}
}
}
}
}
}
' | java \
-cp "${lib}/*" \
-Dlog4j.configurationFile=${bin}/log4j2.xml \
org.xbib.tools.Runner \
org.xbib.tools.JDBCImporter
现在设置的是每分钟执行一次这个sh文件,每执行一次数据都会上传一次,重复数据,不管有没有更新数据都会上传,请问这个时间改怎么改合适?