When trying to search the elasticsearch
using elasticsearch.js
I used the following code below:
var cliente = new $.es.Client({
host: 'http://localhost:9200',
log: 'trace'
});
var cliente = new conectES();
cliente.search({
index: 'usuarios',
body: {
query:
{
fields: ['login'],
query: '2'
}
}// body
}).then(function (resp) {
var hits = resp.hits.hits;
console.log('response: ' + JSON.stringify(hits));
}, function (err) {
console.trace(err.message);
});
The expected response to this search was simply that documents with the loginUsuario
field contain the 2
value to be returned.
Server response Bad request (400)
Expected JSON:
{
"_index" : "Estrutura",
"_type" : "usuarios",
"_id" : "2",
"_version" : 2,
"found" : true,
"_source" : {
"json" : {
"login" : "2",
"nome" : "Foo",
"sobrenome" : "Latex",
"endereco" : "Rua 2 ",
"telefone" : "55 99 999x0-928N",
"foto" : ""
}
}
}