SDK
SDK Javascript v7.x
2

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.


searchSpecifications([body], [options]);

ArgumentsTypeDescription
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:

const body = {
  query: {
    match_all: {
      boost: 1
    }
  }
};

options #

ArgumentsTypeDescription
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
timeout
number

(-1)
Time (in ms) during which a request will still be waited to be resolved. Set it -1 if you want to wait indefinitely
  • 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. | triggerEvents |
    boolean

    (false)| If set to true, will trigger events even if using Embeded SDK. You should always ensure that your events/pipes does not create an infinite loop.
    Available since Kuzzle 2.31.0
    |

Resolves #

Resolve to a SpecificationsSearchResult.

Usage #

try {
  const body = {
    query: {
      match_all: {
        boost: 1
      }
    }
  };
  const options = {
    size: 50,
    offset: 0,
    scroll: '10s'
  };
  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);
}