gpt4 book ai didi

powershell - XDELETE 不删除 ElasticSearch 中的索引

转载 作者:行者123 更新时间:2023-12-02 22:23:42 25 4
gpt4 key购买 nike

我创建了两个文件,

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 在创建索引时使用了删除索引。

最佳答案

我还首先尝试从 elastic.co 获取可复制粘贴的 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/")

关于powershell - XDELETE 不删除 ElasticSearch 中的索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40168253/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com