弹性.js + Node.js:查询没有意义



正如在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"
}

弹性.js(满量程)在 npm 上坏了吗(因为我知道它在 AngularJS 上工作)?还是我忘了猜测全尺寸文档中没有的东西?

谢谢。

由于某些原因,我们现在需要使用方法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(...);

然后它起作用了。

如果有些人真的可以解释为什么会这样,我会保持开放。无论如何,谢谢。

最新更新