SDK
SDK Java v2.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.

searchUsers #

Return users matching the given filter.


searchUsers(filters, [options], callback) #

ArgumentsTypeDescription
filtersJSON ObjectFilter in Elasticsearch's Query DSL format
optionsJSON ObjectOptional parameters
callbackfunctionCallback handling the response

Options #

OptionTypeDescriptionDefault
fromnumberStarting offset0
queuablebooleanMake this request queuable or nottrue
scrollstringStart a scroll session, with a time to live equals to this parameter's value following the Elastisearch time formatundefined
sizenumberNumber of hits to return per result page10

To get more information about scroll sessions, please refer to the API reference documentation.


Callback Response #

Return a JSON Object

Usage #

JSONObject filter = new JSONObject()
  .put("bool", new JSONObject()
    .put("must", new JSONArray()
      .put(new JSONObject()
        .put("terms", new JSONObject()
          .put("profileIds", new JSONArray().put("anonymous").put("default"))
        )
      )
      .put(new JSONObject()
        .put("geoDistance", new JSONObject()
          .put("distance", "10km")
          .put("pos", new JSONObject()
            .put("lat", 48.8566140)
            .put("lon", 2.352222)
          )
        )
      )
    )
  );
// optional: result pagination configuration
Options options = new Options();
options.setFrom((long) 0);
options.setSize((long) 42);
options.setScroll("1m");
kuzzle
  .security
  .searchUsers(filters, options, new ResponseListener<SecurityDocumentList>() {
    @Override
    public void onSuccess(SecurityDocumentList users) {
      // users.getDocuments() returns an users list
      for(User user : users.getDocuments()) {
      }
      // Total number of profiles, regardless of pagination
      long total = users.getTotal();
      // Available only if a "scroll" option has been provided
      String scrollId = users.getScroll()
    }
    @Override
    public void onError(JSONObject error) {
    }
  });

Callback response:

{
  "total": 124,
  "users": [
    // array of User objects
  ],
  // only if a scroll parameter has been provided
  "scrollId": "<scroll identifier>"
}