gpt4 book ai didi

elasticsearch - 即使在logstash.conf中配置了文档ID,也没有在ElasticSearch中设置文档ID

转载 作者:行者123 更新时间:2023-12-03 00:49:45 24 4
gpt4 key购买 nike

Here是我的logstash.conf中的内容。

(不直接在此处粘贴内容的道歉。StackOverflow不允许代码与文本比率过高的问题。)

作为测试,我运行了PowerShell命令

C:\Users\Me\Downloads\curl-7.64.1-win64-mingw\bin> .\curl.exe -XPUT 'http://127.0.0.1:31311/twitter_new/7'



我在Logstash终端上看到以下输出:
{
"message" => "",
"@version" => "1",
"host" => "127.0.0.1",
"@timestamp" => 2019-04-09T11:35:22.458Z,
"request_path_length" => 3,
"headers" => {
"http_host" => "127.0.0.1:31311",
"content_length" => "0",
"request_path" => [
[0] "",
[1] "twitter_new",
[2] "7"
],
"http_accept" => "*/*",
"http_version" => "HTTP/1.1",
"http_user_agent" => "curl/7.64.1",
"request_method" => "PUT"
},
"index_id" => "twitter_new"
}

如您所见,即使我期望如此, document_id并未设置为 7

我怎样才能解决这个问题?

更新:

我变了
if [request_path_length == 3] {


if [request_path_length] == 3 {

我向 PUT发出了另一个 /twitter_new/8请求。然后,我发出了 GET请求以检索所有条目,而这是与我最新提出的 PUT请求相对应的条目:
{
"_index": "twitter_new",
"_type": "doc",
"_id": "O5AIAmoBCWsefMj-o7Fw",
"_score": 1,
"_source": {
"message": "",
"document_id": "8",
"@version": "1",
"@timestamp": "2019-04-09T12:18:00.665Z",
"index_id": "twitter_new",
"request_path_length": 3,
"headers": {
"request_path": [
"",
"twitter_new",
"8"
],
"http_accept": "*/*",
"http_version": "HTTP/1.1",
"content_length": "0",
"request_method": "PUT",
"http_user_agent": "curl/7.64.1",
"http_host": "127.0.0.1:31311"
},
"host": "127.0.0.1"
}
}

如您所见,在 source内, document_id确实设置为 8,但是 _id仍然是随机生成的字符串。我希望 _id也是 8,就像 _indextwitter_new一样。

我误会了吗?

最佳答案

您需要更改条件。

这是引用logstash管道上的字段的正确方法:
if [request_path_length] == 3
您正在使用if [request_path_length == 3],它不起作用。

关于elasticsearch - 即使在logstash.conf中配置了文档ID,也没有在ElasticSearch中设置文档ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55592177/

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