尝试索引文档会产生错误:"在序列化设置中只允许使用值列表"

时间:2018-05-11 17:40:04

标签: elasticsearch search indexing document elasticsearch-6

尝试索引以下文档时:

{
"branch": "master",
"classes": [
    {
        "content_count": 2,
        "documentation": "",
        "extends": [],
        "generic": "",
        "implements": [],
        "line": 10,
        "line_count": 36,
        "modifiers": [
            "public"
        ],
        "name": "removeDuplicateFromString"
    }
],
"commit_hash": "e53249ba2381d2f20f3d4493ad70e2da0abb3b05",
"contributors": [
    {
        "id": "7676016",
        "name": "varunu28",
        "url": "https://github.com/varunu28"
    }
],
"enums": [],
"fields": [],
"filename": "removeDuplicateFromString.java",
"imports": [
    {
        "name": "java.io.BufferedReader",
        "wildcard": false
    },
    {
        "name": "java.io.InputStreamReader",
        "wildcard": false
    }
],
"interfaces": [],
"license": "",
"methods": [
    {
        "cyclomatic_complexity": 1,
        "documentation": "",
        "generic": "",
        "line": 11,
        "line_count": 9,
        "modifiers": [
            "public",
            "static"
        ],
        "name": "main",
        "params": [
            {
                "name": "args",
                "type": "String[]"
            }
        ],
        "parent": "removeDuplicateFromString",
        "type_": "void"
    },
    {
        "cyclomatic_complexity": 5,
        "documentation": "",
        "generic": "",
        "line": 29,
        "line_count": 16,
        "modifiers": [
            "public",
            "static"
        ],
        "name": "removeDuplicate",
        "params": [
            {
                "name": "s",
                "type": "String"
            }
        ],
        "parent": "removeDuplicateFromString",
        "type_": "String"
    }
],
"number_forks": 1695,
"number_stars": 4000,
"number_watchs": 394,
"package": "",
"path": "Others",
"repository": "TheAlgorithms/Java"
}

我收到以下错误:

{"error":{"root_cause":[{"type":"settings_exception","reason":"Failed to load settings from [{\"interfaces\":[],\"imports\":[{\"name\":\"java.io.BufferedReader\",\"wildcard\":false},{\"name\":\"java.io.InputStreamReader\",\"wildcard\":false}],\"package\":\"\",\"methods\":[{\"parent\":\"removeDuplicateFromString\",\"line_count\":9,\"line\":11,\"documentation\":\"\",\"name\":\"main\",\"cyclomatic_complexity\":1,\"modifiers\":[\"public\",\"static\"],\"params\":[{\"name\":\"args\",\"type\":\"String[]\"}],\"type_\":\"void\",\"generic\":\"\"},{\"parent\":\"removeDuplicateFromString\",\"line_count\":16,\"line\":29,\"documentation\":\"\",\"name\":\"removeDuplicate\",\"cyclomatic_complexity\":5,\"modifiers\":[\"public\",\"static\"],\"params\":[{\"name\":\"s\",\"type\":\"String\"}],\"type_\":\"String\",\"generic\":\"\"}],\"number_forks\":1695,\"classes\":[{\"implements\":[],\"line_count\":36,\"extends\":[],\"line\":10,\"documentation\":\"\",\"name\":\"removeDuplicateFromString\",\"content_count\":2,\"modifiers\":[\"public\"],\"generic\":\"\"}],\"repository\":\"TheAlgorithms/Java\",\"branch\":\"master\",\"commit_hash\":\"e53249ba2381d2f20f3d4493ad70e2da0abb3b05\",\"enums\":[],\"path\":\"Others\",\"license\":\"\",\"filename\":\"removeDuplicateFromString.java\",\"number_watchs\":394,\"contributors\":[{\"name\":\"varunu28\",\"id\":\"7676016\",\"url\":\"https://github.com/varunu28\"}],\"fields\":[],\"number_stars\":4000}]"}],"type":"settings_exception","reason":"Failed to load settings from [{\"interfaces\":[],\"imports\":[{\"name\":\"java.io.BufferedReader\",\"wildcard\":false},{\"name\":\"java.io.InputStreamReader\",\"wildcard\":false}],\"package\":\"\",\"methods\":[{\"parent\":\"removeDuplicateFromString\",\"line_count\":9,\"line\":11,\"documentation\":\"\",\"name\":\"main\",\"cyclomatic_complexity\":1,\"modifiers\":[\"public\",\"static\"],\"params\":[{\"name\":\"args\",\"type\":\"String[]\"}],\"type_\":\"void\",\"generic\":\"\"},{\"parent\":\"removeDuplicateFromString\",\"line_count\":16,\"line\":29,\"documentation\":\"\",\"name\":\"removeDuplicate\",\"cyclomatic_complexity\":5,\"modifiers\":[\"public\",\"static\"],\"params\":[{\"name\":\"s\",\"type\":\"String\"}],\"type_\":\"String\",\"generic\":\"\"}],\"number_forks\":1695,\"classes\":[{\"implements\":[],\"line_count\":36,\"extends\":[],\"line\":10,\"documentation\":\"\",\"name\":\"removeDuplicateFromString\",\"content_count\":2,\"modifiers\":[\"public\"],\"generic\":\"\"}],\"repository\":\"TheAlgorithms/Java\",\"branch\":\"master\",\"commit_hash\":\"e53249ba2381d2f20f3d4493ad70e2da0abb3b05\",\"enums\":[],\"path\":\"Others\",\"license\":\"\",\"filename\":\"removeDuplicateFromString.java\",\"number_watchs\":394,\"contributors\":[{\"name\":\"varunu28\",\"id\":\"7676016\",\"url\":\"https://github.com/varunu28\"}],\"fields\":[],\"number_stars\":4000}]","caused_by":{"type":"illegal_state_exception","reason":"only value lists are allowed in serialized settings"}},"status":500}

我从中收集到的主要问题要么在部分中描述:

{"type":"illegal_state_exception","reason":"only value lists are allowed in serialized settings"}}

或者:

"error":{"root_cause":[{"type":"settings_exception","reason":"Failed to load settings from [{\"interfaces\":[],\"imports\": ........

但我无法找到有关此错误的任何信息或可能由此引起的错误。我尝试使用带映射的预定义索引和不存在的索引来编制索引。似乎没什么用。

为什么我无法将此文档编入索引?

2 个答案:

答案 0 :(得分:1)

事实证明,就像Farid在评论部分中提到的那样,当我从命令行索引时,我使用了错误的命令。

正确的命令是

curl -X POST -H 'Content-Type: application/json' [index location] -d [data]

关键是你使用POST而不是PUT,这就是我正在做的事情。

答案 1 :(得分:0)

使用Kibana开发工具将其添加到其中。 关键是在添加文档时在索引名称后使用文档类型

POST /{index name}/{document type}
{
   request body (document) goes here.
}