@Test public void getObjectAttributes() throws AlgoliaException { for (String id : ids) { JSONObject object = index.getObject(id, null); assertEquals("The retrieved object should have 3 attributes.", 3, object.names().length()); object = index.getObject(id, Collections.singletonList("city"), null); assertEquals("The retrieved object should have 2 attributes.", 2, object.names().length()); assertNotNull("The retrieved object should have an `objectID` attribute.", object.optString("objectID", null)); assertNotNull("The retrieved object should have a `city` attribute.", object.optString("city", null)); } }
public JSONObject getObject(String objectID, @Nullable RequestOptions requestOptions) throws AlgoliaException { try { return client.getRequest("/1/indexes/" + encodedIndexName + "/" + URLEncoder.encode(objectID, "UTF-8"), null, false, requestOptions); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
Index extends Searchable { public JSONObject getObject(String objectID, @Nullable RequestOptions requestOptions) throws AlgoliaException { try { return client.getRequest("/1/indexes/" + encodedIndexName + "/" + URLEncoder.encode(objectID, "UTF-8"), null, false, requestOptions); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } }
Index extends Searchable { public JSONObject getObject(String objectID, @Nullable RequestOptions requestOptions) throws AlgoliaException { try { return client.getRequest("/1/indexes/" + encodedIndexName + "/" + URLEncoder.encode(objectID, "UTF-8"), null, false, requestOptions); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } protected  Index(@NonNull Client client, @NonNull String rawIndexName); }
Index extends Searchable { public JSONObject getObject(String objectID, @Nullable RequestOptions requestOptions) throws AlgoliaException { try { return client.getRequest("/1/indexes/" + encodedIndexName + "/" + URLEncoder.encode(objectID, "UTF-8"), null, false, requestOptions); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } protected  Index(@NonNull Client client, @NonNull String rawIndexName); @Override String toString(); String getRawIndexName(); Client getClient(); Request searchAsync(@Nullable Query query, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); JSONObject searchSync(@Nullable Query query, @Nullable RequestOptions requestOptions); JSONObject searchSync(@Nullable Query query); Request multipleQueriesAsync(final @NonNull Collection<Query> queries, final Client.MultipleQueriesStrategy strategy, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request multipleQueriesAsync(final @NonNull Collection<Query> queries, final Client.MultipleQueriesStrategy strategy, @Nullable CompletionHandler completionHandler); @Override Request searchDisjunctiveFacetingAsync(@NonNull Query query, @NonNull final Collection<String> disjunctiveFacets, @NonNull final Map<String, ? extends Collection<String>> refinements, @Nullable final RequestOptions requestOptions, @NonNull final CompletionHandler completionHandler); Request searchDisjunctiveFacetingAsync(@NonNull Query query, @NonNull final Collection<String> disjunctiveFacets, @NonNull final Map<String, ? extends Collection<String>> refinements, @NonNull final CompletionHandler completionHandler); Request searchForFacetValuesAsync(@NonNull String facetName, @NonNull String text, @NonNull final CompletionHandler handler); Request searchForFacetValues(@NonNull String facetName, @NonNull String text, @NonNull final CompletionHandler handler); Request searchForFacetValuesAsync(@NonNull String facetName, @NonNull String facetText, @Nullable Query query, @NonNull final CompletionHandler handler); @Override Request searchForFacetValuesAsync(@NonNull String facetName, @NonNull String facetText, @Nullable Query query, @Nullable final RequestOptions requestOptions, @NonNull final CompletionHandler handler); Request searchForFacetValues(@NonNull String facetName, @NonNull String facetText, @Nullable Query query, @NonNull final CompletionHandler handler); Request addObjectAsync(final @NonNull JSONObject object, @Nullable CompletionHandler completionHandler); Request addObjectAsync(final @NonNull JSONObject object, final @NonNull String objectID, @Nullable CompletionHandler completionHandler); Request addObjectAsync(final @NonNull JSONObject object, final @NonNull String objectID, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request addObjectsAsync(final @NonNull JSONArray objects, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request addObjectsAsync(final @NonNull JSONArray objects, @Nullable CompletionHandler completionHandler); Request saveObjectAsync(final @NonNull JSONObject object, final @NonNull String objectID, @Nullable CompletionHandler completionHandler); Request saveObjectAsync(final @NonNull JSONObject object, final @NonNull String objectID, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request saveObjectsAsync(final @NonNull JSONArray objects, @Nullable CompletionHandler completionHandler); Request saveObjectsAsync(final @NonNull JSONArray objects, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request partialUpdateObjectAsync(final @NonNull JSONObject partialObject, final @NonNull String objectID, @Nullable CompletionHandler completionHandler); Request partialUpdateObjectAsync(final @NonNull JSONObject partialObject, final @NonNull String objectID, final boolean createIfNotExists, @Nullable CompletionHandler completionHandler); Request partialUpdateObjectAsync(final @NonNull JSONObject partialObject, final @NonNull String objectID, final boolean createIfNotExists, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request partialUpdateObjectsAsync(final @NonNull JSONArray partialObjects, @Nullable CompletionHandler completionHandler); Request partialUpdateObjectsAsync(final @NonNull JSONArray partialObjects, final boolean createIfNotExists, @Nullable CompletionHandler completionHandler); Request partialUpdateObjectsAsync(final @NonNull JSONArray partialObjects, final boolean createIfNotExists, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request getObjectAsync(final @NonNull String objectID, @Nullable CompletionHandler completionHandler); Request getObjectAsync(final @NonNull String objectID, final Collection<String> attributesToRetrieve, @Nullable CompletionHandler completionHandler); Request getObjectAsync(final @NonNull String objectID, final Collection<String> attributesToRetrieve, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request getObjectsAsync(final @NonNull Collection<String> objectIDs, @Nullable CompletionHandler completionHandler); Request getObjectsAsync(final @NonNull Collection<String> objectIDs, final List<String> attributesToRetrieve, @Nullable CompletionHandler completionHandler); Request getObjectsAsync(final @NonNull Collection<String> objectIDs, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request getObjectsAsync(final @NonNull Collection<String> objectIDs, final Collection<String> attributesToRetrieve, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request waitTaskAsync(final @NonNull String taskID, @Nullable CompletionHandler completionHandler); Request waitTaskAsync(final long taskID, @Nullable CompletionHandler completionHandler); Request deleteObjectAsync(final @NonNull String objectID, @Nullable CompletionHandler completionHandler); Request deleteObjectAsync(final @NonNull String objectID, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request deleteObjectsAsync(final @NonNull Collection<String> objectIDs, @Nullable CompletionHandler completionHandler); Request deleteObjectsAsync(final @NonNull Collection<String> objectIDs, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request deleteByQueryAsync(@NonNull Query query, @Nullable CompletionHandler completionHandler); Request deleteByQueryAsync(@NonNull Query query, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request deleteByAsync(@NonNull Query query, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request deleteByAsync(@NonNull Query query, @Nullable CompletionHandler completionHandler); Request getSettingsAsync(@Nullable CompletionHandler completionHandler); Request getSettingsAsync(@Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request setSettingsAsync(final @NonNull JSONObject settings, @Nullable CompletionHandler completionHandler); Request setSettingsAsync(final @NonNull JSONObject settings, final boolean forwardToReplicas, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request browseAsync(@NonNull Query query, @Nullable CompletionHandler completionHandler); Request browseAsync(@NonNull Query query, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request browseFromAsync(final @NonNull String cursor, @Nullable CompletionHandler completionHandler); Request browseFromAsync(final @NonNull String cursor, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request clearIndexAsync(@Nullable CompletionHandler completionHandler); Request clearIndexAsync(@Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); void enableSearchCache(); void enableSearchCache(int timeoutInSeconds, int maxRequests); void disableSearchCache(); void clearSearchCache(); JSONObject addObject(JSONObject obj, @Nullable RequestOptions requestOptions); JSONObject addObject(JSONObject obj, String objectID, @Nullable RequestOptions requestOptions); JSONObject addObjects(JSONArray inputArray, @Nullable RequestOptions requestOptions); JSONObject getObject(String objectID, @Nullable RequestOptions requestOptions); JSONObject getObject(String objectID, Collection<String> attributesToRetrieve, @Nullable RequestOptions requestOptions); JSONObject getObjects(Collection<String> objectIDs); JSONObject getObjects(@NonNull Collection<String> objectIDs, @Nullable Collection<String> attributesToRetrieve, @Nullable RequestOptions requestOptions); JSONObject partialUpdateObject(JSONObject partialObject, String objectID, Boolean createIfNotExists, @Nullable RequestOptions requestOptions); JSONObject partialUpdateObjects(JSONArray inputArray, boolean createIfNotExists, @Nullable RequestOptions requestOptions); JSONObject saveObject(JSONObject object, String objectID, @Nullable RequestOptions requestOptions); JSONObject saveObjects(JSONArray inputArray, @Nullable RequestOptions requestOptions); JSONObject deleteObject(String objectID, @Nullable RequestOptions requestOptions); JSONObject deleteObjects(Collection<String> objects, @Nullable RequestOptions requestOptions); @Deprecated void deleteByQuery(@NonNull Query query, @Nullable RequestOptions requestOptions); JSONObject deleteBy(@NonNull Query query); JSONObject deleteBy(@NonNull Query query, RequestOptions requestOptions); JSONObject search(@Nullable Query query, @Nullable RequestOptions requestOptions); JSONObject waitTask(String taskID, long timeToWait); JSONObject waitTask(String taskID); JSONObject getSettings(@Nullable RequestOptions requestOptions); JSONObject getSettings(int formatVersion, @Nullable RequestOptions requestOptions); JSONObject setSettings(JSONObject settings); JSONObject setSettings(JSONObject settings, boolean forwardToReplicas, @Nullable RequestOptions requestOptions); JSONObject clearIndex(@Nullable RequestOptions requestOptions); }
Index extends Searchable { public JSONObject getObject(String objectID, @Nullable RequestOptions requestOptions) throws AlgoliaException { try { return client.getRequest("/1/indexes/" + encodedIndexName + "/" + URLEncoder.encode(objectID, "UTF-8"), null, false, requestOptions); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } protected  Index(@NonNull Client client, @NonNull String rawIndexName); @Override String toString(); String getRawIndexName(); Client getClient(); Request searchAsync(@Nullable Query query, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); JSONObject searchSync(@Nullable Query query, @Nullable RequestOptions requestOptions); JSONObject searchSync(@Nullable Query query); Request multipleQueriesAsync(final @NonNull Collection<Query> queries, final Client.MultipleQueriesStrategy strategy, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request multipleQueriesAsync(final @NonNull Collection<Query> queries, final Client.MultipleQueriesStrategy strategy, @Nullable CompletionHandler completionHandler); @Override Request searchDisjunctiveFacetingAsync(@NonNull Query query, @NonNull final Collection<String> disjunctiveFacets, @NonNull final Map<String, ? extends Collection<String>> refinements, @Nullable final RequestOptions requestOptions, @NonNull final CompletionHandler completionHandler); Request searchDisjunctiveFacetingAsync(@NonNull Query query, @NonNull final Collection<String> disjunctiveFacets, @NonNull final Map<String, ? extends Collection<String>> refinements, @NonNull final CompletionHandler completionHandler); Request searchForFacetValuesAsync(@NonNull String facetName, @NonNull String text, @NonNull final CompletionHandler handler); Request searchForFacetValues(@NonNull String facetName, @NonNull String text, @NonNull final CompletionHandler handler); Request searchForFacetValuesAsync(@NonNull String facetName, @NonNull String facetText, @Nullable Query query, @NonNull final CompletionHandler handler); @Override Request searchForFacetValuesAsync(@NonNull String facetName, @NonNull String facetText, @Nullable Query query, @Nullable final RequestOptions requestOptions, @NonNull final CompletionHandler handler); Request searchForFacetValues(@NonNull String facetName, @NonNull String facetText, @Nullable Query query, @NonNull final CompletionHandler handler); Request addObjectAsync(final @NonNull JSONObject object, @Nullable CompletionHandler completionHandler); Request addObjectAsync(final @NonNull JSONObject object, final @NonNull String objectID, @Nullable CompletionHandler completionHandler); Request addObjectAsync(final @NonNull JSONObject object, final @NonNull String objectID, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request addObjectsAsync(final @NonNull JSONArray objects, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request addObjectsAsync(final @NonNull JSONArray objects, @Nullable CompletionHandler completionHandler); Request saveObjectAsync(final @NonNull JSONObject object, final @NonNull String objectID, @Nullable CompletionHandler completionHandler); Request saveObjectAsync(final @NonNull JSONObject object, final @NonNull String objectID, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request saveObjectsAsync(final @NonNull JSONArray objects, @Nullable CompletionHandler completionHandler); Request saveObjectsAsync(final @NonNull JSONArray objects, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request partialUpdateObjectAsync(final @NonNull JSONObject partialObject, final @NonNull String objectID, @Nullable CompletionHandler completionHandler); Request partialUpdateObjectAsync(final @NonNull JSONObject partialObject, final @NonNull String objectID, final boolean createIfNotExists, @Nullable CompletionHandler completionHandler); Request partialUpdateObjectAsync(final @NonNull JSONObject partialObject, final @NonNull String objectID, final boolean createIfNotExists, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request partialUpdateObjectsAsync(final @NonNull JSONArray partialObjects, @Nullable CompletionHandler completionHandler); Request partialUpdateObjectsAsync(final @NonNull JSONArray partialObjects, final boolean createIfNotExists, @Nullable CompletionHandler completionHandler); Request partialUpdateObjectsAsync(final @NonNull JSONArray partialObjects, final boolean createIfNotExists, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request getObjectAsync(final @NonNull String objectID, @Nullable CompletionHandler completionHandler); Request getObjectAsync(final @NonNull String objectID, final Collection<String> attributesToRetrieve, @Nullable CompletionHandler completionHandler); Request getObjectAsync(final @NonNull String objectID, final Collection<String> attributesToRetrieve, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request getObjectsAsync(final @NonNull Collection<String> objectIDs, @Nullable CompletionHandler completionHandler); Request getObjectsAsync(final @NonNull Collection<String> objectIDs, final List<String> attributesToRetrieve, @Nullable CompletionHandler completionHandler); Request getObjectsAsync(final @NonNull Collection<String> objectIDs, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request getObjectsAsync(final @NonNull Collection<String> objectIDs, final Collection<String> attributesToRetrieve, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request waitTaskAsync(final @NonNull String taskID, @Nullable CompletionHandler completionHandler); Request waitTaskAsync(final long taskID, @Nullable CompletionHandler completionHandler); Request deleteObjectAsync(final @NonNull String objectID, @Nullable CompletionHandler completionHandler); Request deleteObjectAsync(final @NonNull String objectID, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request deleteObjectsAsync(final @NonNull Collection<String> objectIDs, @Nullable CompletionHandler completionHandler); Request deleteObjectsAsync(final @NonNull Collection<String> objectIDs, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request deleteByQueryAsync(@NonNull Query query, @Nullable CompletionHandler completionHandler); Request deleteByQueryAsync(@NonNull Query query, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request deleteByAsync(@NonNull Query query, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request deleteByAsync(@NonNull Query query, @Nullable CompletionHandler completionHandler); Request getSettingsAsync(@Nullable CompletionHandler completionHandler); Request getSettingsAsync(@Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request setSettingsAsync(final @NonNull JSONObject settings, @Nullable CompletionHandler completionHandler); Request setSettingsAsync(final @NonNull JSONObject settings, final boolean forwardToReplicas, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request browseAsync(@NonNull Query query, @Nullable CompletionHandler completionHandler); Request browseAsync(@NonNull Query query, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request browseFromAsync(final @NonNull String cursor, @Nullable CompletionHandler completionHandler); Request browseFromAsync(final @NonNull String cursor, @Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); Request clearIndexAsync(@Nullable CompletionHandler completionHandler); Request clearIndexAsync(@Nullable final RequestOptions requestOptions, @Nullable CompletionHandler completionHandler); void enableSearchCache(); void enableSearchCache(int timeoutInSeconds, int maxRequests); void disableSearchCache(); void clearSearchCache(); JSONObject addObject(JSONObject obj, @Nullable RequestOptions requestOptions); JSONObject addObject(JSONObject obj, String objectID, @Nullable RequestOptions requestOptions); JSONObject addObjects(JSONArray inputArray, @Nullable RequestOptions requestOptions); JSONObject getObject(String objectID, @Nullable RequestOptions requestOptions); JSONObject getObject(String objectID, Collection<String> attributesToRetrieve, @Nullable RequestOptions requestOptions); JSONObject getObjects(Collection<String> objectIDs); JSONObject getObjects(@NonNull Collection<String> objectIDs, @Nullable Collection<String> attributesToRetrieve, @Nullable RequestOptions requestOptions); JSONObject partialUpdateObject(JSONObject partialObject, String objectID, Boolean createIfNotExists, @Nullable RequestOptions requestOptions); JSONObject partialUpdateObjects(JSONArray inputArray, boolean createIfNotExists, @Nullable RequestOptions requestOptions); JSONObject saveObject(JSONObject object, String objectID, @Nullable RequestOptions requestOptions); JSONObject saveObjects(JSONArray inputArray, @Nullable RequestOptions requestOptions); JSONObject deleteObject(String objectID, @Nullable RequestOptions requestOptions); JSONObject deleteObjects(Collection<String> objects, @Nullable RequestOptions requestOptions); @Deprecated void deleteByQuery(@NonNull Query query, @Nullable RequestOptions requestOptions); JSONObject deleteBy(@NonNull Query query); JSONObject deleteBy(@NonNull Query query, RequestOptions requestOptions); JSONObject search(@Nullable Query query, @Nullable RequestOptions requestOptions); JSONObject waitTask(String taskID, long timeToWait); JSONObject waitTask(String taskID); JSONObject getSettings(@Nullable RequestOptions requestOptions); JSONObject getSettings(int formatVersion, @Nullable RequestOptions requestOptions); JSONObject setSettings(JSONObject settings); JSONObject setSettings(JSONObject settings, boolean forwardToReplicas, @Nullable RequestOptions requestOptions); JSONObject clearIndex(@Nullable RequestOptions requestOptions); static final int DEFAULT_SETTINGS_VERSION; }