sareem
sareem

Reputation: 429

Elasticsearch multi search API

I'm trying to perform multiple concurrent search requests using Elasticsearch (version 6). Here is my queries file:

{"index" : "web"}
{"max_concurrent_searches": 64, "query": {"match": {"content": "school"}}}
{"index" : "web"}
{"max_concurrent_searches": 64, "query": {"match": {"content": "car"}}}
{"index" : "web"}
{"max_concurrent_searches": 64, "query": {"match": {"content": "cat"}}}

Here is the command I use to issue the bulk request:

curl -H "Content-Type: application/x-ndjson" -XGET ''$url'/_msearch'
--data-binary "@$file"; echo

However, I get the following error indicating my wrong usage of max_concurrent_searches parameter.

{"error":{"root_cause":[{"type":"parsing_exception","reason":"Unknown key for a VALUE_NUMBER in [max_concurrent_searches].","line":1,"col":29}],"type":"parsing_exception","reason":"Unknown key for a VALUE_NUMBER in [max_concurrent_searches].","line":1,"col":29},"status":400}

If I removed "max_concurrent_searches": 64, from the queries file above, everything works just perfect.

I want to know how can I use/set the max_concurrent_searches parameter, I couldn't find useful information in Elasticsearch documentation about this except the following:

The msearch’s max_concurrent_searches request parameter can be used to control the maximum number of concurrent searches the multi search api will execute. This default is based on the number of data nodes and the default search thread pool size.

Upvotes: 0

Views: 5130

Answers (2)

hi.nitish
hi.nitish

Reputation: 2984

You can execute above using postman also. Just change the content-type as application/x-ndjson and dont forget to add a new line character in the end. This will give you the same error and you can correct it easily by different combinations. MultiSearch is an important feature.

Upvotes: 0

Anurag
Anurag

Reputation: 91

You should add it to the request itself:

Sample request: GET indexName/type/_msearch?max_concurrent_searches=1100 (where indexName and type is optional)

For you its should be like:

curl -H "Content-Type: application/x-ndjson" -XGET ''$url'/_msearch**? 
max_concurrent_searches=1100**'
--data-binary "@$file"; echo

Upvotes: 1

Related Questions