SDK
SDK Javascript v6.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

searchSpecifications #

Searches collection specifications.

There is a limit to how many items can be returned by a single search query. That limit is by default set at 10000, and you can't get over it even with the from and size pagination options.

When processing a large number of items (i.e. more than 1000), it is advised to paginate the results using SearchResult.next rather than increasing the size parameter.


Copied to clipboard!
searchSpecifications([body], [options]);

Arguments Type Description
body
object
An object containing the search query
options
object
Query options

body #

The body is a set of filters using Elasticsearch Query DSL to match the documents you are looking for. The filters must be inside the query property of the body.

Example:

Copied to clipboard!
const body = {
  query: {
    match_all: {
      boost: 1
    }
  }
};

options #

Arguments Type Description
queuable
boolean

(true)
Make this request queuable or not
from
number

(0)
Offset of the first document
size
number

(10)
Maximum number of documents returned
scroll
string

Maximum duration for scroll session
  • size controls the maximum number of documents returned in the response
  • from is usually used with the size argument, and defines the offset from the first result you want to fetch
  • scroll is used to fetch large result sets, and it must be set with a time duration. If set, a forward-only cursor will be created (and automatically destroyed at the end of the set duration), and its identifier will be returned in the scrollId property, along with the first page of the results.

Resolves #

Resolve to a SpecificationsSearchResult.

Usage #

Copied to clipboard!
try {
  const body = {
    query: {
      match_all: {
        boost: 1
      }
    }
  };
  const options = {
    size: 50,
    offset: 0,
    scroll: '10m'
  };
  const searchResult = await kuzzle.collection.searchSpecifications(body, options);
  console.log(searchResult);
  /*
    {
      "total": 1,
      "max_score": 1,
      "hits": [
        {
          "_index": "%kuzzle",
          "_type": "validations",
          "_id": "nyc-open-data#yellow-taxi",
          "_score": 1,
          "_source": {
            "validation": {
              "strict": false,
              "fields": {
                "license": {
                  "type": "string"
                }
              }
            },
            "index": "nyc-open-data",
            "collection": "yellow-taxi"
          }
        }
      ],
      "scrollId": "DnF1ZXJ5VGhlbkZldGNoBQAAAAAAAACSFlgtZTJFYjNiU1FxQzhSNUFpNlZHZGcAAAAAAAAAkxZYLWUyRWIzYlNRcUM4UjVBaTZWR2RnAAAAAAAAAJQWWC1lMkViM2JTUXFDOFI1QWk2VkdkZwAAAAAAAACVFlgtZTJFYjNiU1FxQzhSNUFpNlZHZGcAAAAAAAAAlhZYLWUyRWIzYlNRcUM4UjVBaTZWR2Rn"
    }
  */
} catch (error) {
  console.error(error.message);
}