SDK
SDK Java v3.x
2

This SDK is deprecated. We recommend to use the Kuzzle SDK-JVM.
A migration guide is available here

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.


public CompletableFuture<SearchResult> searchSpecifications(
      final ConcurrentHashMap<String, Object> searchQuery,
      final SearchOptions options) throws NotConnectedException, InternalException

public CompletableFuture<SearchResult> searchSpecifications(
      final ConcurrentHashMap<String, Object> searchQuery) throws NotConnectedException, InternalException

ArgumentsTypeDescription
searchQuery
ConcurrentHashMap<String, Object>
An object containing the search query
options
SearchOptions
Query options

searchQuery body properties: #

An empty body matches all documents in the queried collection.

options #

A SearchOptions object.

The following options can be set:

OptionsType
(default)
Description
from
Integer

(0)
Offset of the first document to fetch
size
Integer

(10)
Maximum number of documents to retrieve per page
scroll
String

("")
When set, gets a forward-only cursor having its ttl set to the given value (ie 1s; cf elasticsearch time limits)

Return #

Returns a SearchResult object.

Usage #

ConcurrentHashMap<String, Object> searchQuery = new ConcurrentHashMap<>();
ConcurrentHashMap<String, Object> filters = new ConcurrentHashMap<>();
ConcurrentHashMap<String, Object> args = new ConcurrentHashMap<>();
filters.put("match_all", args);
searchQuery.put("query", filters);
SearchOptions options = new SearchOptions();
options.setSize(50);
options.setFrom(0);
options.setScroll("10s");
SearchResult result = kuzzle
  .getCollectionController()
  .searchSpecifications(searchQuery, options).get();
System.out.println("fetched: " + result.fetched);
  /*
    {
      "total"=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"
    }
  */