How do I pass the query variable in client.search?

myapp.factory('dataervice',
['$q', 'esFactory', '$location', function ($q, elasticsearch, $location) {

        var client = elasticsearch({
            host: 'https://mywebsitelink.in'
        });
        var search = function (term, offset) {

               var deferred = $q.defer();
            var query = {
                match: {
                    "title": term,
                    "url": term,
                    "content": term
                },
                size: 10,
                from: (offset || 0) * 10,
            };
            client.search({
                HOW TO PASS THE QERY PARAMETER HERE FOR ELASTIC SEARCH 
            })
            .then(function (result) {
                //console.log(result);
                var ii = 0, hits_in, hits_out = [];
                hits_in = (result.hits || {}).hits || [];
                for (; ii < hits_in.length; ii++) {
                    if (hits_in[ii]._source.content != null)
                        hits_out.push(hits_in[ii]._source);
                }
                deferred.resolve(hits_out);
            }, deferred.reject
            );
            return deferred.promise;
        };
        return {
            search: search
        };
    }]);

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.