0
When trying to do a search on elasticsearch
using the 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 research was simply that the documents with the field loginUsuario
, contain the value 2
were returned.
Server response Bad request (400)
JSON expected:
{
"_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" : ""
}
}
}