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

3
我正在尝试为我的MongoDB创建一个弹性搜索河流。我正在使用“elasticsearch-mapper-attachments”和“elasticsearch-river-mongodb”插件。问题在于,我收到了关于“java.lang.String不能转换为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
}
1个回答

1

已修复。我将一个 string 传递到了 index 字段中:

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

相反,我需要将一个对象传递到索引字段中:

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

这个对象在Elasticsearch内部可能表示为java.util.Map,因为它们描述了objects。在其他语言中,它被称为哈希、哈希映射、字典或关联数组。因此,这解释了错误信息:java.lang.String不能转换为java.util.Map

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接