SDK
SDK Jvm v1.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.


:::: tabs ::: tab Java

Arguments #

Copied to clipboard!
public CompletableFuture<SearchResult> searchSpecifications(
      Map<String, Object> searchQuery,
      String scroll,
      Integer from,
      Integer size) throws NotConnectedException, InternalException

public CompletableFuture<SearchResult> searchSpecifications(
      Map<String, Object> searchQuery,
      String scroll,
      Integer from) throws NotConnectedException, InternalException

public CompletableFuture<SearchResult> searchSpecifications(
      Map<String, Object> searchQuery,
      String scroll) throws NotConnectedException, InternalException

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

Arguments Type Description
searchQuery
Map<String, Object>
An object containing the search query
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 (e.g. 1s; see elasticsearch time limits)

searchQuery body properties: #

An empty body matches all documents in the queried collection.

Return #

Returns a SearchResult object.

Usage #

Copied to clipboard!
Map<String, Object> searchQuery = new HashMap<>();
Map<String, Object> filters = new HashMap<>();
Map<String, Object> args = new HashMap<>();
filters.put("match_all", args);
searchQuery.put("query", filters);
SearchResult result = kuzzle
  .getCollectionController()
  .searchSpecifications(searchQuery, "10s", 0, 50).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"
    }
  */

::: ::: tab Kotlin

Arguments #

Copied to clipboard!
fun searchSpecifications(
    searchQuery: Map<String, Any?>,
    scroll: String? = null,
    from: Int = 0,
    size: Int? = null
  ): CompletableFuture<SearchResult>

Arguments Type Description
searchQuery
Map<String, Any?>
An object containing the search query
from
Int

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

(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)

searchQuery body properties: #

An empty body matches all documents in the queried collection.

Return #

Returns a SearchResult object.

Usage #

Copied to clipboard!
val args: Map<String, Any?> = HashMap<String, Any?>()
val filters: Map<String, Any?> =
HashMap<String, Any?>().apply {
  put("match_all", args)
}
val searchQuery: Map<String, Any?> =
HashMap<String, Any?>().apply {
  put("query", filters)
}
val result: SearchResult = kuzzle
  .collectionController
  .searchSpecifications(searchQuery, "10s", 0, 50).get();
print("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"
    }
  */

::: ::::