我创建了两个文件,
jdbc_sqlserver.json
:
{
"type": "jdbc",
"jdbc": {
"url": "jdbc:sqlserver://localhost:1433;databaseName=merchant2merchant;integratedSecurity=true;",
"user": "",
"password": "",
"sql": "select * from planets",
"treat_binary_as_string": true,
"elasticsearch": {
"cluster": "elasticsearch",
"host": "localhost",
"port": 9200
},
"index": "testing"
}
jdb_sqlserver.ps1
:
function Get-PSVersion {
if (Test-Path variable:PSVersionTable) {
$PSVersionTable.PSVersion
} else {
[version]"1.0.0.0"
}
}
$powershell = Get-PSVersion
if ($powershell.Major -le 2) {
Write-Error "Oh, so sorry, this script requires Powershell 3 (due to ConvertTo-Json)"
exit
}
if ((Test-Path env:\JAVA_HOME) -eq $false) {
Write-Error "Environment variable JAVA_HOME must be set to your java home"
exit
}
curl -XDELETE "http://localhost:9200/users/"
$DIR = "C:\Program Files\elasticsearch\plugins\elasticsearch-jdbc-2.3.4.0-dist\elasticsearch-jdbc-2.3.4.0\"
$FEEDER_CLASSPATH = "$DIR\lib"
$FEEDER_LOGGER = "file://$DIR\bin\log4j2.xml"
java -cp "$FEEDER_CLASSPATH\*" -Dlog4j.configurationFile=$FEEDER_LOGGER"
"org.xbib.tools.Runner"
"org.xbib.tools.JDBCImporter"
jdbc_sqlserver.json
我很困惑,在ElasticSearch中,XDELETE在创建索引时使用了删除索引。
答案 0 :(得分:2)
我还首先尝试从elastic.co获取copy-pasteable snippet-curl-commands以在PowerShell中工作(在版本4中)。 PowerShell有一个curl的别名(as discussed here),但它看起来并没有遵循相同的语法。
所以在我看来,最好将curl
- 调用转换为Invoke-WebRequest
- 完全调用。
要使用PowerShell删除索引,只需使用此命令
Invoke-WebRequest -Uri 'http://localhost:9200/users/' -Method Delete
(翻译自curl -XDELETE "http://localhost:9200/users/"
)