gpt4 book ai didi

java - 以[。]开头或结尾的object字段使elasticsearch bulk index中的对象分辨率不明确

转载 作者:行者123 更新时间:2023-12-03 02:25:41 27 4
gpt4 key购买 nike

我正在使用带有Java Rest高级客户端的Elasticsearch 6.8.7版本。根据提供的文档here,我编写了一个程序,该程序使用批量处理器对一些数据批量索引到elasticsearch。

问题是当我运行代码时,响应失败并显示以下消息:

[type=illegal_argument_exception, reason=object field starting or ending with a [.] makes object resolution ambiguous



这很奇怪,因为我手动索引了其中一个文档,并且成功完成了而没有任何问题。

这是发出索引请求的代码部分:
        String key = entry.getKey();
JSONObject val = entry.getValue();
bulkProcessor.add(new IndexRequest("tweet").type("json").id(key).source(val, XContentType.JSON));

这是json的示例(上面的val):

{"in_reply_to_status_id_str":null,"in_reply_to_status_id":null,"coordinates":null,"created_at":"Mon Apr 06 23:59:47 +0000 2020","truncated":false,"in_reply_to_user_id_str":null,"source":"http://twitter.com/download/iphone\" rel=\"nofollow\">Twitter for iPhone</a>","retweet_count":0,"retweeted":false,"geo":null,"in_reply_to_screen_name":null,"is_quote_status":false,"id_str":"11111111111111","in_reply_to_user_id":null,"favorite_count":7,"id":1111111111111,"text":"something","place":null,"contributors":null,"lang":"en","favorited":false}



如果有人对为什么会这样有任何想法,我将非常感谢他们的帮助。

更新:
我更改了索引,但没有改变,但这是我在 flex 端子中得到的错误:

object field starting or ending with a [.] makes object resolution ambiguous: [{"possibly_sensitive_appealable":false,"in_reply_to_status_id_str":null,"in_reply_to_status_id":null,"created_at":"Mon Apr 06 23:59:49 +0000 2020","in_reply_to_user_id_str":null,"source":"http://twitter.com/download/android\" rel=\"nofollow\">Twitter for Android</a>","quoted_status_id":1111111111111,"retweet_count":0,"retweeted":false,"geo":null,"in_reply_to_screen_name":null,"is_quote_status":true,"id_str":"111111111111","in_reply_to_user_id":null,"favorite_count":15,"id":1247313090397589511,"text":"something","place":null,"lang":"fa","favorited":false,"possibly_sensitive":false,"coordinates":null,"truncated":false,"quoted_status_id_str":"1111111111111","contributors":null}]

最佳答案

我遇到了同样的问题,尝试验证属性,显然索引properties中的所有GET /index_name都存储为String而不是JSON对象。
如果是这种情况:
最初的问题出在Kafka ConsumerRecord raw上,我没有设置ConsumerRecord<String, String>类型,问题就解决了。
另一种选择是使用特定的Encoding对字符串进行编码,它也对我有用。
例如

IndexRequest indexRequest = new IndexRequest("twitter")
.source(record.value().getBytes(StandardCharsets.US_ASCII), XContentType.JSON);
IndexResponse indexResponse = client.index(indexRequest, RequestOptions.DEFAULT);
String id = indexResponse.getId();
log.info(id);
我不确定这是否可以帮助您,但就我而言,我通过这些更改解决了问题。

关于java - 以[。]开头或结尾的object字段使elasticsearch bulk index中的对象分辨率不明确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61122845/

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