Я пытался написать запрос _msearch asticsearch в Nodejs. Но я получаю следующую ошибку
{"module":"Search","type":"Success","response":{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"The msearch request must be terminated by a newline [\n]"}],"type":"illegal_argument_exception","reason":"The msearch request must be terminated by a newline [\n]"},"status":400}}
Я создал шаблон поиска вasticsearch, используя kibana. Это работает в кибане. Я попытался добавить \n
в конце строки, все еще получая ту же ошибку. Вот мой полный код.
let doc=`{"index":"my_index"}
{ "id": "count", "params": { "domain":"'+domain+'", "condition":"attributes.sent", "value":"0" } }
{"index":"my_index"}
{ "id": "count", "params": { "domain":"'+domain+'", "condition":"attributes.status", "value":"open" } }
{"index":"my_index"}
{ "id": "count", "params": { "domain":"'+domain+'", "condition":"attributes.status", "value":"click" } }
{"index":"my_index"}
{ "id": "count", "params": { "domain":"'+domain+'", "condition":"attributes.status", "value":"bounce" } }
`;
let reqObj = {
uri: API_URL+INDEX+'_msearch/template',
method: 'GET',
headers: { "content-type": "application/json" },
body: doc,
json: true
};
return new Promise((resolve,reject)=>{
request(reqObj, (err, res, body) => {
if(err) return reject(this.Response("Search","error",err));
return resolve(this.Response("Search","Success",body));
});
});
Я пытался удалить лишние пробелы, все тот же результат
let doc=`{"index":"my_index"}{ "id": "count", "params": { "domain":"'+domain+'", "condition":"attributes.sent", "value":"0" } }{"index":"my_index"}{ "id": "count", "params": { "domain":"'+domain+'", "condition":"attributes.status", "value":"open" } }{"index":"my_index"}{ "id": "count", "params": { "domain":"'+domain+'", "condition":"attributes.status", "value":"click" } }{"index":"my_index"}{ "id": "count", "params": { "domain":"'+domain+'", "condition":"attributes.status", "value":"bounce" } }`;