I need to make some request with the MultiSearch API from Jest. I tried to build Search request like this :
Search search = new Search.Builder(query).addIndex(index).addType(type).build();
And then, I add all these requests into a collection, to build the MultiSearch and get the result, like this :
List<Search> ms = new ArrayList<Search>();
for (#iterate over#) {
ms.add(search())
//Adding the searches queries to the List
}
MultiSearch multi = new MultiSearch.Builder(ms).build();
MultiSearchResult multir = client.execute(multi);
But this return this error from elasticsearch :
{
"error": {
"caused_by": {
"reason": "Unexpected end-of-input: expected close marker for Object (start marker at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@2ccf4bb6; line: 1, column: 1])\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@2ccf4bb6; line: 2, column: 3]",
"type": "json_e_o_f_exception"
},
"reason": "Exception when parsing search request",
"root_cause": [
{
"reason": "Exception when parsing search request",
"type": "parse_exception"
}
],
"type": "parse_exception"
},
"status": 400
}
So my question is, how to perform MultiSearch request with jest ?
Well, after tests, I found a solution :
Search search = new Search.Builder(query.toString().replaceAll("\\n|\\r", "")).addIndex(es_index_data)
.addType(es_type_data).build();