searchSpecifications

const
  filters = {
    match_all: {
      boost: 1
    }
  },
  options= {
    from: 0,
    size: 20
  };

// Using callbacks (NodeJS or Web Browser)
kuzzle
  .collection('collection', 'index')
  .searchSpecifications(filters, options, function (err, res) {
    res.hits.forEach(function (specification) {
      console.log(specification);
    });

    res.total // Total specifications count
  });

// Using promises (NodeJS only)
kuzzle
  .collection('collection', 'index')
  .searchSpecificationsPromise(filters, options)
  .then(res => {
    res.hits.forEach(specification => {
      console.log(specification);
    });

    res.total // Total specifications count
  });
import io.kuzzle.sdk.core.Kuzzle;
import io.kuzzle.sdk.core.Options; 

Kuzzle kuzzle = new Kuzzle("localhost");

JSONObject filters = new JSONObject()
   .put("match_all", new JSONObject()
       .put("boost", 1)
   );

Options options = new Options();
options.setFrom((long) 0);
options.setSize((long) 20);

kuzzle
  .collection("collection", "index")
  .searchSpecifications(filters, options, new ResponseListener<JSONObject>() {
    @Override
    public void onSuccess(JSONObject res) {
      for (int i = 0; i < res.getJSONArray("hits").length(); i++) {
        res.getJSONArray("hits").getJSONObject(i) // Specification
      }

      res.getString("total"); // Total specifications count
    }

    @Override
    public void onError(JSONObject error) {
      // Handle error
    }
  });
<?php

use \Kuzzle\Kuzzle;

$filters = [
    "match_all" => [
        "boost" => 1
    ]
];

$options = [
  'from' => 0,
  'size' => 20
];

$kuzzle = new Kuzzle('localhost');
$dataCollection = $kuzzle->collection('collection', 'index');

try {
  $res = $dataCollection->searchSpecifications($filters, $options);

  foreach ($res['hits'] as $specification) {
    // Specification
  }

  // Total specifications count
  $res['total'];
}
catch (ErrorException $e) {

}

Callback response

{
  "hits": [
    {"first": "specification"},
    {"second": "specification"}
  ],
  "total": 2,
  "scrollId": "foobar"
}

Retrieves every specifications across indexes/collections according to the given filters.


searchSpecifications(filters, [options], callback)

ArgumentsTypeDescription
filtersJSON objectSearch request body, using ElasticSearch Query DSL format.
If given an empty object, matches all specifications across index/collections
optionsJSON objectOptional parameters
callbackfunctionCallback handling the response

Options

OptionTypeDescriptionDefault
fromnumberProvide the starting offset of the request (used to paginate results)0
queuablebooleanMark this request as (not) queuabletrue
scrollstringStart a scroll session, with a time to live equals to this parameter's value following the Elastisearch time formatundefined
sizenumberProvide the maximum number of results of the request (used to paginate results)10