curl -X GET --user user:pass "localhost:port/element1-2021.07.06/_msearch?pretty" -H 'Content-Type: application/json' -d'
{ }
{"query": {"match" : {"application":"Scanner"}}}
{"index": "element1-2021.07.06"}
{"query" : {"match":{"processed.Severity":"ERROR"}}}
'
When I run the query above I'm getting:
{
"type" : "json_parse_exception",
"reason" : "Unexpected character ('\' (code 92)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: (org.elasticsearch.common.io.stream.ByteBufferStreamInput); line: 1, column: 2]"
}
Could anyone give me a hand please?
wild guess: You should not start with an empty line, as the first line should contain the metadata of your first document.
I have done it as well I get the same result, Alexander please give a hand mate there is no much information on _msearch thanks a lot.
$ curl -X GET --user user:pass "localhost:port/element1-2021.07.06/_msearch?pretty" -H "Content-Type: application/json" -d'
{"query": {"match" : {"application":"Scanner"}}}
{"index": "element1-2021.07.06"}
{"query" : {"match":{"processed.Severity":"ERROR"}}}
'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 816 100 656 100 160 1898 463 --:--:-- --:--:-- --:--:-- 2365{
"error" : {
"root_cause" : [
{
"type" : "json_parse_exception",
"reason" : "Unexpected character ('\' (code 92)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: (org.elasticsearch.common.io.stream.ByteBufferStreamInput); line: 1, column: 2]"
}
],
"type" : "json_parse_exception",
"reason" : "Unexpected character ('\' (code 92)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: (org.elasticsearch.common.io.stream.ByteBufferStreamInput); line: 1, column: 2]"
},
"status" : 400
}
the way your example is formatted, your first line is an empty line and does not have any content. If that is not the case please provide a more exact reproduction.
You can use the --trace-ascii
parameter in curl to write a log how your data is sent. This will allow you to verify what data your are sending.
It is set in the same exact way your documentation mentions it:
Multi search API | Elasticsearch Guide [7.13] | Elastic
curl -X GET "localhost:9200/my-index-000001/_msearch?pretty" -H 'Content-Type: application/json' -d'
{ }
{"query" : {"match" : { "message": "this is a test"}}}
{"index": "my-index-000002"}
{"query" : {"match_all" : {}}}
'
Just to be sure, we get this properly reproduced:
- You went to the first example, clicked on
copy as curl
- Pasted this in your terminal
- Received the above error?
I just did the same and it worked for me, so I suppose there must be a slight difference in what we did.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.