loopbackio / loopback-connector-elastic-search

Strongloop Loopback connector for Elasticsearch
MIT License
79 stars 56 forks source link

support for ES compatible DSL in .count #38

Closed slorf closed 8 years ago

slorf commented 8 years ago

add support for ES compatible DSL in .count through 'where.native' key

slnode commented 8 years ago

Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test."

pulkitsinghal commented 8 years ago

Seems reasonable, @slorf: just for sanity's sake, is it safe to assume you've run this code once and used it?

slorf commented 8 years ago

Yes, I have. Thank you for the swift response.

pulkitsinghal commented 7 years ago

I'm having second thoughts about these changes:

    var body = where.native ? where.native : {
        query: self.buildWhere(modelName, idName, where).query
    };

Why wasn't buildWhere().query which performed:

        else if (criteria.native) {
            filter.body = criteria.native; // assume that the developer has provided ES compatible DSL
        }

sufficient? What was it returning that was a mismatch?

I will think on it more and report back here what I concluded and if any changes will be coming soon.

slorf commented 7 years ago

buildWhere always adds the body-key to query, which is not required in _count