0

As seen on the official documentation of FullScale, I've got :

// 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);
});

And everything seems to work, except when I look closely to the results that have absolutely nothing to do with 'exemple', like :

{
    "field": "something that have absolutely nothing to do with anything"
},
{
    "field": "lolwut i don't even know how to elasticsearch"
},
{
    "field": "kthxbye"
}

Is the elastic.js (fullscale) broken on npm (because I know it's working on AngularJS) ? or have I forgot to guess something that wasn't in the FullScale documentation ?

Thanks.

Romain
  • 3,586
  • 7
  • 31
  • 52

1 Answers1

0

For some reasons, we now need to use the method toString as follow :

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(...);

And then it works.

I'll leave it open if some people can actually explains why it is so. Thanks anyway.

Romain
  • 3,586
  • 7
  • 31
  • 52