lib/indexer.js
function formQuery(params, callback) {
  params = params || { query: {}};

  var query = formQueryLib.createFormQuery(params);
  var q = {
    _source : params.sourceFields || sourceFields,
    sort : params.sort || [
      { "timestamp" : {"order" : "desc"}},
    ],
    from: params.from || 0,
    size : querySize(params),
    query: query
  };
  if (params.query && params.query.terms) {
    q.highlight = { fields: {"title" : {}, "text" : {}}};
  }

  getEs().search({ _index : GLOBAL.config.ESEARCH._index, _type : 'contentItem'}, q, function(err, res) {
    if (err) {
      utils.passingError(err, params);

    } else {
      res.from = params.from || 0;
      res.query = q;
      if (!res || res.hits.hits.length < 1) {
        GLOBAL.debug('NO HITS FOR', JSON.stringify(q, null, 2));
      }
    }
    formQueryLib.filter(params.filters, res);
    callback(err, res);
  });
}
function formQuery(params, callback) {
  params = params || { query: {}};

  var query = formQueryLib.createFormQuery(params);
  var q = {
    _source : params.sourceFields || sourceFields,
    sort : params.sort || [
      { "timestamp" : {"order" : "desc"}},
    ],
    from: params.from || 0,
    size : querySize(params),
    query: query
  };
  if (params.query && params.query.terms) {
    q.highlight = { fields: {"title" : {}, "text" : {}}};
  }

  getEs().search({ _index : GLOBAL.config.ESEARCH._index, _type : 'contentItem'}, q, function(err, res) {
    if (err) {
      utils.passingError(err, params);

    } else {
      res.from = params.from || 0;
      res.query = q;
      if (!res || res.hits.hits.length < 1) {
        GLOBAL.debug('NO HITS FOR', JSON.stringify(q, null, 2));
      }
    }
    formQueryLib.filter(params.filters, res);
    callback(err, res);
  });
}
function formQuery ( params , callback ) { params = params || { query : { } } ; var query = formQueryLib . createFormQuery ( params ) ; var q = { _source : params . sourceFields || sourceFields , sort : params . sort || [ { "timestamp" : { "order" : "desc" } } , ] , from : params . from || 0 , size : querySize ( params ) , query : query } ; if ( params . query && params . query . terms ) { q . highlight = { fields : { "title" : { } , "text" : { } } } ; } getEs ( ) . search ( { _index : GLOBAL . config . ESEARCH . _index , _type : 'contentItem' } , q , function ( err , res ) { if ( err ) { utils . passingError ( err , params ) ; } else { res . from = params . from || 0 ; res . query = q ; if ( ! res || res . hits . hits . length < 1 ) { GLOBAL . debug ( 'NO HITS FOR' , JSON . stringify ( q , null , 2 ) ) ; } } formQueryLib . filter ( params . filters , res ) ; callback ( err , res ) ; } ) ; }
Executes form params, returning results
Executes form params returning results