Skip to content

Bulk query gives error #24

@karl-sjogren

Description

@karl-sjogren

I'm trying out a bulk-query as follows.

POST _bulk
{ "index" : { "_index" : "esdemo-reviews"} }
{ "title": "22/11 1963", "by": "King, Stephen", "reviewer": "Sonja Viklund", "preamble": "En man reser femtio år tillbaka i tiden för att försöka skriva om historien och hindra mordet på John F Kennedy." }
{ "index" : { "_index" : "esdemo-reviews"} }
{ "title": "4.50 från Paddington", "by": "Christie, Agatha", "reviewer": "Helen Forsberg", "preamble": "När polisen inte lyssnar på mrs McGillicuddy när hon vill rapportera ett mord, vänder hon sig till sin vän miss Marple." }

But when I run it I get an error about a missing new line at the end of the request.

{
    "statusCode": 400,
    "body": {
        "error": {
            "root_cause": [
                {
                    "type": "illegal_argument_exception",
                    "reason": "The bulk request must be terminated by a newline [\\n]"
                }
            ],
            "type": "illegal_argument_exception",
            "reason": "The bulk request must be terminated by a newline [\\n]"
        },
        "status": 400
    },
    "headers": {
        "content-type": "application/json; charset=UTF-8",
        "x-powered-by": "ARR/3.0",
        "date": "Thu, 30 Jan 2020 06:58:38 GMT",
        "connection": "close",
        "content-length": "245"
    },
    "request": {
        "uri": {
            "protocol": "https:",
            "slashes": true,
            "auth": "...",
            "host": "...",
            "port": "9201",
            "hostname": "...",
            "hash": null,
            "search": null,
            "query": null,
            "pathname": "//_bulk",
            "path": "//_bulk",
            "href": "https://.../_bulk"
        },
        "method": "POST",
        "headers": {
            "Accept": "application/json",
            "Content-Type": "application/x-ndjson",
            "content-length": 948
        }
    },
    "message": "Bad Request",
    "completed": false,
    "environment": {
        "_textTokens": [
            {
                "_index": 0,
                "_isValid": true,
                "_depth": -1,
                "_text": null,
                "_offset": 0,
                "_type": 0
            },
            {
                "_index": 0,
                "_isValid": true,
                "_depth": 0,
                "_text": "host",
                "_offset": 8,
                "_type": 5,
                "_path": "host",
                "_propertyValueToken": {
                    "_index": 0,
                    "_isValid": true,
                    "_depth": -1,
                    "_text": "https:/.../",
                    "_offset": 16,
                    "_type": 6
                }
            },
            {
                "_index": 0,
                "_isValid": true,
                "_depth": 0,
                "_text": "name",
                "_offset": 123,
                "_type": 5,
                "_path": "name",
                "_propertyValueToken": {
                    "_index": 0,
                    "_isValid": true,
                    "_depth": -1,
                    "_text": "default",
                    "_offset": 131,
                    "_type": 6
                }
            }
        ],
        "_version": {
            "_major": "7",
            "_minor": "4",
            "_patch": "2"
        },
        "_host": "https://.../",
        "_name": "default"
    }
}

The same also happens if I try the query from the demo repo.

https://github.com/Crasnam/vscode-elasticdeveloper/blob/3ac43d9e290ea73e038f9e4d3e4858e20d1074ce/demo/eslorem/version_7.3.2/queries/index/populate_bulk.esquery#L5-L18

I'm running VSCode 1.41.1 against Elasticsearch 7.4.2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions