MultiSearch with 2 different indexes

Hi,
I'm trying to implement a multi search which query two different indexes. As my ES version is 5.3, I'm following this documentation:

I've done a few multi-search before and I've gotten no problem, but when I want to specify the index to be queried I'm getting parsing errors.

I'm using NodeJS and also Insomnia client to test it but I'm not able to query them correctly.

My code is like this:

await this.client.msearch({
	body: [
		{"index": "myIndex1"},
		{ bodyQuery },
		{"index": "myIndex2"},
		{ bodyQuery }
	]	
});

This is returning this error:

{
  "error": {
"root_cause": [
  {
    "type": "parsing_exception",
    "reason": "Unknown key for a VALUE_STRING in [index].",
    "line": 1,
    "col": 10
  }
],
"type": "parsing_exception",
"reason": "Unknown key for a VALUE_STRING in [index].",
"line": 1,
"col": 10
  },
  "status": 400
}

I've tested the query independently and it works. If I try to execute this it works:

await this.client.msearch({
body: [
{},
{ bodyQuery },
{},
{ bodyQuery }
]
});

Can you help me with this or point me to a example, please?

Thank you,
Antonio.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.