我在节点JS中执行ElasticSearch。通过“client.search”,我可以从elasticsearch中获取数据,但我只想获取“源”字段。我该怎么做??
通过javascript的“map”函数,我只能得到源数据。
但是,我想知道“client.search”中的body选项是什么,以仅获取源数据。
这是我使用map函数的代码。
index: 'bank',
body:{
query:{
"bool":{
"must":{"match":{"state":"AL"}}
}
}
}
}, function getMore(err,data){
if(err)
{
console.log(err);
return;
}
var source = data.hits.hits.map(function(obj){
return obj._source;
});
console.log(source);
res.end(source);
});