gpt4 book ai didi

java - Elasticsearch River - java.lang.String 无法转换为 java.util.Map

转载 作者:可可西里 更新时间:2023-11-01 10:43:22 27 4
gpt4 key购买 nike

我正在尝试为我的 MongoDB 创建一个 Elastic search river。我正在使用 elasticsearch-mapper-attachmentselasticsearch-river-mongodb 插件。我遇到的问题是我收到有关 java.lang.String cannot be cast to java.util.Map

的投诉

这是我创建的索引:

{
"type": "mongodb",
"mongodb": {
"collection": "config_files",
"db": "tore_dev"
},
"index": "config_files"
}

命令如下:

one@old-dash ~/river $ curl -X PUT "localhost:9200/_river/config_files/_meta" -d @create.json |  python -m json.tool
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 220 100 84 100 136 3032 4909 --:--:-- --:--:-- --:--:-- 5230
{
"_id": "_meta",
"_index": "_river",
"_type": "config_files",
"_version": 1,
"created": true
}
one@old-dash ~/river $

这是它的状态:

one@old-dash ~/river $ curl localhost:9200/_river/config_files/_status |  python -m json.tool
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 640 100 640 0 0 30247 0 --:--:-- --:--:-- --:--:-- 33684
{
"_id": "_status",
"_index": "_river",
"_source": {
"error": "CreationException[Guice creation errors:\n\n1) Error injecting constructor, java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map\n at org.elasticsearch.river.mongodb.MongoDBRiver.<init>(Unknown Source)\n while locating org.elasticsearch.river.mongodb.MongoDBRiver\n while locating org.elasticsearch.river.River\n\n1 error]; nested: ClassCastException[java.lang.String cannot be cast to java.util.Map]; ",
"node": {
"id": "57f4LnVMSn2xDlo1Es0meQ",
"name": "Wicked",
"transport_address": "inet[/10.1.23.69:9300]"
}
},
"_type": "config_files",
"_version": 1,
"found": true
}

最佳答案

已修复。我将 string 传递到 index 字段:

    ...
"index": "config_files"
....

相反,我需要 pass an object进入索引字段:

{
"type": "mongodb",
"mongodb": {
"collection": "config_files",
"db": "tore_dev"
},
"index": {
"name": "mongo_index",
"type": "config_files"
}
}

该对象可能在 Elasticsearch 内部表示为 java.util.Map,因为它们描述了对象:

 known in other languages as a hash, hashmap, dictionary or associative array.

所以这解释了错误消息,java.lang.String cannot be cast to java.util.Map

关于java - Elasticsearch River - java.lang.String 无法转换为 java.util.Map,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27846549/

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