UserID as _id 这样的话可以增量同步,_id是es的默认id命名
"interval":"1800", 这里是同步数据的频率 1800s,半小时,可以按需要设成 1s或其它
XDELETE 参数路径格式: url/_index/_type/_id
引自:https://github.com/jprante/elasticsearch-jdbc/
strategy
- the strategy of the JDBC plugin, currently implemented: "simple"
, "column"
schedule
- a single or a list of cron expressions for scheduled execution. Syntax is equivalent to the Quartz cron expression format (see below).
threadpoolsize
- a thread pool size for the scheduled executions for schedule
parameter. If set to 1
, all jobs will be executed serially. Default is 4
.
interval
- a time value for the delay between two river runs (default: not set)
max_bulk_actions
- the length of each bulk index request submitted (default: 10000)
max_concurrent_bulk_requests
- the maximum number of concurrent bulk requests (default: 2 * number of CPU cores)
max_bulk_volume
- a byte size parameter for the maximum volume allowed for a bulk request (default: "10m")
max_request_wait
- a time value for the maximum wait time for a response of a bulk request (default: "60s")
flush_interval
- a time value for the interval period of flushing index docs to a bulk action (default: "5s")
url
- the JDBC driver URL
user
- the JDBC database user
password
- the JDBC database password
sql
- SQL statement(s), either a string or a list. If a statement ends with .sql, the statement is looked up in the file system. Example for a list of SQL statements:
"sql" : [
{
"statement" : "select ... from ... where a = ?, b = ?, c = ?",
"parameter" : [ "value for a", "value for b", "value for c" ]
},
{
"statement" : "insert into ... where a = ?, b = ?, c = ?",
"parameter" : [ "value for a", "value for b", "value for c" ],
"write" : "true"
},
{
"statement" : ...
}
]
sql.statement
- the SQL statement
sql.write
- boolean flag, if true, the SQL statement is interpreted as an insert/update statement that needs write access (default: false).
sql.callable
- boolean flag, if true, the SQL statement is interpreted as a JDBC CallableStatement
for stored procedures (default: false).
sql.parameter
- bind parameters for the SQL statement (in order). Some special values can be used with the following meanings:
$now
- the current timestamp$job
- a job counter$count
- last number of rows merged$river.name
- the river name$last.sql.start
- a timestamp value for the time when the last SQL statement started$last.sql.end
- a timestamp value for the time when the last SQL statement ended$last.sql.sequence.start
- a timestamp value for the time when the last SQL sequence started$last.sql.sequence.end
- a timestamp value for the time when the last SQL sequence ended$river.state.started
- the timestamp of river start (from river state)$river.state.timestamp
- last timestamp of river activity (from river state)$river.state.counter
- counter from river state, counts the numbers of runs locale
- the default locale (used for parsing numerical values, floating point character. Recommended values is "en_US")
timezone
- the timezone for JDBC setTimestamp() calls when binding parameters with timestamp values
rounding
- rounding mode for parsing numeric values. Possible values "ceiling", "down", "floor", "halfdown", "halfeven", "halfup", "unnecessary", "up"
scale
- the precision of parsing numeric values
autocommit
- true
if each statement should be automatically executed. Default is false
fetchsize
- the fetchsize for large result sets, most drivers use this to control the amount of rows in the buffer while iterating through the result set
max_rows
- limit the number of rows fetches by a statement, the rest of the rows is ignored
max_retries
- the number of retries to (re)connect to a database
max_retries_wait
- a time value for the time that should be waited between retries. Default is "30s"
resultset_type
- the JDBC result set type, can be TYPE_FORWARD_ONLY, TYPE_SCROLL_SENSITIVE, TYPE_SCROLL_INSENSITIVE. Default is TYPE_FORWARD_ONLY
resultset_concurrency
- the JDBC result set concurrency, can be CONCUR_READ_ONLY, CONCUR_UPDATABLE. Default is CONCUR_UPDATABLE
ignore_null_values
- if NULL values should be ignored when constructing JSON documents. Default is false
prepare_database_metadata
- if the driver metadata should be prepared as parameters for acccess by the river. Default is false
prepare_resultset_metadata
- if the result set metadata should be prepared as parameters for acccess by the river. Default is false
column_name_map
- a map of aliases that should be used as a replacement for column names of the database. Useful for Oracle 30 char column name limit. Default is null
query_timeout
- a second value for how long an SQL statement is allowed to be executed before it is considered as lost. Default is 1800
connection_properties
- a map for the connection properties for driver connection creation. Default isnull
index
- the Elasticsearch index used for indexing
type
- the Elasticsearch type of the index used for indexing
index_settings
- optional settings for the Elasticsearch index
type_mapping
- optional mapping for the Elasticsearch index type
{
"strategy" : "simple",
"schedule" : null,
"interval" : 0L,
"threadpoolsize" : 4,
"max_bulk_actions" : 10000,
"max_concurrent_bulk_requests" : 2 * available CPU cores,
"max_bulk_volume" : "10m",
"max_request_wait" : "60s",
"flush_interval" : "5s",
"jdbc" : {
"url" : null,
"user" : null,
"password" : null,
"sql" : null,
"locale" : Locale.getDefault().toLanguageTag(),
"timezone" : TimeZone.getDefault(),
"rounding" : null,
"scale" : 2,
"autocommit" : false,
"fetchsize" : 10, /* MySQL: Integer.MIN */
"max_rows" : 0,
"max_retries" : 3,
"max_retries_wait" : "30s",
"resultset_type" : "TYPE_FORWARD_ONLY",
"resultset_concurreny" : "CONCUR_UPDATABLE",
"ignore_null_values" : false,
"prepare_database_metadata" : false,
"prepare_resultset_metadata" : false,
"column_name_map" : null,
"query_timeout" : 1800,
"connection_properties" : null,
"index" : "jdbc",
"type" : "jdbc",
"index_settings" : null,
"type_mapping" : null,
}
}
Setting a cron expression in the paramter schedule
enables repeated (or time scheduled) runs of JDBC river.
You can also define a list of cron expressions (in a JSON array) to schedule for many different time schedules.
Example of a schedule
paramter:
"schedule" : "0 0-59 0-23 ? * *"
This executes JDBC river every minute, every hour, all the days in the week/month/year.
The following documentation about the syntax of the cron expression is copied from the Quartz scheduler javadoc page.
Cron expressions provide the ability to specify complex time combinations such as "At 8:00am every Monday through Friday" or "At 1:30am every last Friday of the month".
Cron expressions are comprised of 6 required fields and one optional field separated by white space. The fields respectively are described as follows:
Field Name | Allowed Values | Allowed Special Characters |
---|---|---|
Seconds | 0-59 | , - * / |
Minutes | 0-59 | , - * / |
Hours | 0-23 | , - * / |
Day-of-month | 1-31 | , - * ? / L W |
Month | 1-12 or JAN-DEC | , - * / |
Day-of-Week | 1-7 or SUN-SAT | , - * ? / L # |
Year (Optional) | empty, 1970-2199 | , - * / |