query #
Base method used to send queries to Kuzzle, following the API Documentation.
This is a low-level method, exposed to allow advanced SDK users to bypass high-level methods.
::: warn
Calling query directly with a String
or RawJson
causes the SDK to deserialize the query, add some properties, then reserialize the query.
This can decrease performances when giving big JSON payloads.
If you have big JSON body payloads to send, consider using a Map and only use a RawJson for the body property. This will avoid the deserialization + reserialization slowdown :::
query #
All properties necessary for the Kuzzle API can be added in the query object. The following properties are the most common.
Property | Type | Description |
---|---|---|
controller | String | Controller name (mandatory) |
action | String | Action name (mandatory) |
body | Map<String, Object> | Query body for this action |
index | String | Index name for this action |
collection | String | Collection name for this action |
_id | String | id for this action |
volatile | Map<String, Object> | Additional information to send to Kuzzle |
headers | Map<String, Object> | Optionnal headers to send (HTTP Only) |
Returns #
Returns a Response object which represents a raw Kuzzle API response. See the API Documentation.
Usage #
Map<String, Object> query = new HashMap<>();
query.put("controller", "document");
query.put("action", "create");
query.put("index", "nyc-open-data");
query.put("collection", "yellow-taxi");
query.put("_id", "my-custom-document-id");
query.put("refresh", "wait_for");
Map<String, Object> body = new HashMap<>();
body.put("trip_distance", 4.23);
body.put("passenger_count", 2);
query.put("body", body);
Response res = kuzzle.query(query).get();
:::
::: warn
Calling query directly with a String
or RawJson
causes the SDK to deserialize the query, add some properties, then reserialize the query.
This can decrease performances when giving big JSON payloads.
If you have big JSON body payloads to send, consider using a Map and only use a RawJson for the body property. This will avoid the deserialization + reserialization slowdown :::
query #
All properties necessary for the Kuzzle API can be added in the query object. The following properties are the most common.
Property | Type | Description |
---|---|---|
controller | String | Controller name (mandatory) |
action | String | Action name (mandatory) |
body | Map<String, Any?> | Query body for this action |
index | String | Index name for this action |
collection | String | Collection name for this action |
_id | String | id for this action |
volatile | Map<String, Any?> | Additional information to send to Kuzzle |
headers | Map<String, Any?> | Optionnal headers to send (HTTP Only) |
Returns #
Returns a Response object which represents a raw Kuzzle API response. See the API Documentation.
Usage #
val query: Map<String?, Any?> = HashMap<String?, Any?>().apply {
put("controller", "document")
put("action", "create")
put("index", "nyc-open-data")
put("collection", "yellow-taxi")
put("_id", "my-custom-document-id")
put("refresh", "wait_for")
put("body", HashMap<String?, Any?>().apply {
put("trip_distance", 4.23)
put("passenger_count", 2)
})
}
val res: Response = kuzzle.query(query).get()
:::