正如FullScale的官方文档所示,我得到了:
// The official one
var elasticsearch = require('elasticsearch');
var client = new elasticsearch.Client({
host: conf.elastic.server
});
// FullScale one (for some reasons, needing the official one, whereas in AngularJS, same version, used alone. But hey ! I'm not judging.
var ejs = require('elastic.js');
client.search({
index: conf.elastic.indice,
type: conf.elastic.index,
body: ejs.Request().query(ejs.BoolQuery().must(ejs.MatchQuery('field': 'exemple'))
}).then(function(resp) {
_this.sendResponse(null, resp.hits.hits, res);
}, function(args) {
console.trace("Erreur #" + args.status + " : " + args.error);
});
一切似乎都有效,除非我仔细查看与“例证”完全无关的结果,例如:
{
"field": "something that have absolutely nothing to do with anything"
},
{
"field": "lolwut i don't even know how to elasticsearch"
},
{
"field": "kthxbye"
}
在npm上是否打破了elastic.js(fullscale)(因为我知道它正在使用AngularJS)? 或者我忘了猜测FullScale文档中没有的东西?
感谢。
答案 0 :(得分:0)
由于某些原因,我们现在需要使用方法toString,如下所示:
var body = ejs.Request().query(ejs.BoolQuery().must(ejs.MatchQuery('field': 'exemple'))
client.search({
index: conf.elastic.indice,
type: conf.elastic.index,
body: body.toString()
}).then(...);
然后它有效。
如果有些人能够真正解释为什么会这样,我会把它打开。 不管怎样,谢谢。