|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.algolia.search.saas.Index
public class Index
Contains all the functions related to one index You should use APIClient.initIndex(indexName) to retrieve this object
Constructor Summary | |
---|---|
protected |
Index(APIClient client,
String indexName)
Index initialization (You should not call this yourself) |
Method Summary | |
---|---|
org.json.JSONObject |
addObject(org.json.JSONObject obj)
Add an object in this index |
org.json.JSONObject |
addObject(org.json.JSONObject obj,
String objectID)
Add an object in this index with a uniq identifier |
org.json.JSONObject |
addObjects(org.json.JSONArray inputArray)
Add several objects |
org.json.JSONObject |
addObjects(List<org.json.JSONObject> objects)
Add several objects |
org.json.JSONObject |
addUserKey(List<String> acls)
Create a new user key |
org.json.JSONObject |
addUserKey(List<String> acls,
int validity,
int maxQueriesPerIPPerHour,
int maxHitsPerQuery)
Create a new user key |
org.json.JSONObject |
batch(org.json.JSONArray actions)
Custom batch |
org.json.JSONObject |
batch(List<org.json.JSONObject> actions)
Custom batch |
org.json.JSONObject |
browse(int page)
Browse all index content |
org.json.JSONObject |
browse(int page,
int hitsPerPage)
Browse all index content |
org.json.JSONObject |
clearIndex()
Delete the index content without removing settings and index specific API keys. |
void |
deleteByQuery(Query query)
Delete all objects matching a query |
org.json.JSONObject |
deleteObject(String objectID)
Delete an object from the index |
org.json.JSONObject |
deleteObjects(List<String> objects)
Delete several objects |
org.json.JSONObject |
deleteUserKey(String key)
Delete an existing user key |
String |
getIndexName()
|
org.json.JSONObject |
getObject(String objectID)
Get an object from this index. |
org.json.JSONObject |
getObject(String objectID,
List<String> attributesToRetrieve)
Get an object from this index |
org.json.JSONObject |
getObjects(List<String> objectIDs)
Get several objects from this index |
org.json.JSONObject |
getSettings()
Get settings of this index |
org.json.JSONObject |
getUserKeyACL(String key)
Get ACL of a user key |
org.json.JSONObject |
listUserKeys()
List all existing user keys with their associated ACLs |
org.json.JSONObject |
partialUpdateObject(org.json.JSONObject partialObject,
String objectID)
Update partially an object (only update attributes passed in argument) |
org.json.JSONObject |
partialUpdateObjects(org.json.JSONArray inputArray)
Partially Override the content of several objects |
org.json.JSONObject |
partialUpdateObjects(List<org.json.JSONObject> objects)
Partially Override the content of several objects |
org.json.JSONObject |
saveObject(org.json.JSONObject object,
String objectID)
Override the content of object |
org.json.JSONObject |
saveObjects(org.json.JSONArray inputArray)
Override the content of several objects |
org.json.JSONObject |
saveObjects(List<org.json.JSONObject> objects)
Override the content of several objects |
org.json.JSONObject |
search(Query params)
Search inside the index |
org.json.JSONObject |
searchDisjunctiveFaceting(Query query,
List<String> disjunctiveFacets)
|
org.json.JSONObject |
searchDisjunctiveFaceting(Query query,
List<String> disjunctiveFacets,
Map<String,List<String>> refinements)
Perform a search with disjunctive facets generating as many queries as number of disjunctive facets |
org.json.JSONObject |
setSettings(org.json.JSONObject settings)
Set settings for this index |
org.json.JSONObject |
updateUserKey(String key,
List<String> acls)
Update a user key |
org.json.JSONObject |
updateUserKey(String key,
List<String> acls,
int validity,
int maxQueriesPerIPPerHour,
int maxHitsPerQuery)
Update a user key |
void |
waitTask(String taskID)
Wait the publication of a task on the server. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected Index(APIClient client, String indexName)
Method Detail |
---|
public String getIndexName()
public org.json.JSONObject addObject(org.json.JSONObject obj) throws AlgoliaException
obj
- the object to add
AlgoliaException
public org.json.JSONObject addObject(org.json.JSONObject obj, String objectID) throws AlgoliaException
obj
- the object to addobjectID
- the objectID associated to this object
(if this objectID already exist the old object will be overriden)
AlgoliaException
public org.json.JSONObject batch(org.json.JSONArray actions) throws AlgoliaException
actions
- the array of actions
AlgoliaException
public org.json.JSONObject batch(List<org.json.JSONObject> actions) throws AlgoliaException
actions
- the array of actions
AlgoliaException
public org.json.JSONObject addObjects(List<org.json.JSONObject> objects) throws AlgoliaException
objects
- the array of objects to add
AlgoliaException
public org.json.JSONObject addObjects(org.json.JSONArray inputArray) throws AlgoliaException
objects
- the array of objects to add
AlgoliaException
public org.json.JSONObject getObject(String objectID) throws AlgoliaException
objectID
- the unique identifier of the object to retrieve
AlgoliaException
public org.json.JSONObject getObject(String objectID, List<String> attributesToRetrieve) throws AlgoliaException
objectID
- the unique identifier of the object to retrieveattributesToRetrieve,
- contains the list of attributes to retrieve.
AlgoliaException
public org.json.JSONObject getObjects(List<String> objectIDs) throws AlgoliaException
objectIDs
- the array of unique identifier of objects to retrieve
AlgoliaException
public org.json.JSONObject partialUpdateObject(org.json.JSONObject partialObject, String objectID) throws AlgoliaException
partialObject
- the object to override
AlgoliaException
public org.json.JSONObject partialUpdateObjects(org.json.JSONArray inputArray) throws AlgoliaException
objects
- the array of objects to update (each object must contains an objectID attribute)
AlgoliaException
public org.json.JSONObject partialUpdateObjects(List<org.json.JSONObject> objects) throws AlgoliaException
objects
- the array of objects to update (each object must contains an objectID attribute)
AlgoliaException
public org.json.JSONObject saveObject(org.json.JSONObject object, String objectID) throws AlgoliaException
object
- the object to update
AlgoliaException
public org.json.JSONObject saveObjects(List<org.json.JSONObject> objects) throws AlgoliaException
objects
- the array of objects to update (each object must contains an objectID attribute)
AlgoliaException
public org.json.JSONObject saveObjects(org.json.JSONArray inputArray) throws AlgoliaException
objects
- the array of objects to update (each object must contains an objectID attribute)
AlgoliaException
public org.json.JSONObject deleteObject(String objectID) throws AlgoliaException
objectID
- the unique identifier of object to delete
AlgoliaException
public void deleteByQuery(Query query) throws AlgoliaException
query
- the query stringparams
- the optional query parameters
AlgoliaException
public org.json.JSONObject search(Query params) throws AlgoliaException
AlgoliaException
public org.json.JSONObject deleteObjects(List<String> objects) throws AlgoliaException
objects
- the array of objectIDs to delete
AlgoliaException
public org.json.JSONObject browse(int page) throws AlgoliaException
page
- Pagination parameter used to select the page to retrieve.
Page is zero-based and defaults to 0. Thus, to retrieve the 10th page you need to set page=9
AlgoliaException
public org.json.JSONObject browse(int page, int hitsPerPage) throws AlgoliaException
page
- Pagination parameter used to select the page to retrieve.
Page is zero-based and defaults to 0. Thus, to retrieve the 10th page you need to set page=9hitsPerPage:
- Pagination parameter used to select the number of hits per page. Defaults to 1000.
AlgoliaException
public void waitTask(String taskID) throws AlgoliaException
taskID
- the id of the task returned by server
AlgoliaException
public org.json.JSONObject getSettings() throws AlgoliaException
AlgoliaException
public org.json.JSONObject clearIndex() throws AlgoliaException
AlgoliaException
public org.json.JSONObject setSettings(org.json.JSONObject settings) throws AlgoliaException
settigns
- the settings object that can contains :
- minWordSizefor1Typo: (integer) the minimum number of characters to accept one typo (default = 3).
- minWordSizefor2Typos: (integer) the minimum number of characters to accept two typos (default = 7).
- hitsPerPage: (integer) the number of hits per page (default = 10).
- attributesToRetrieve: (array of strings) default list of attributes to retrieve in objects.
If set to null, all attributes are retrieved.
- attributesToHighlight: (array of strings) default list of attributes to highlight.
If set to null, all indexed attributes are highlighted.
- attributesToSnippet**: (array of strings) default list of attributes to snippet alongside the number of words to return (syntax is attributeName:nbWords).
By default no snippet is computed. If set to null, no snippet is computed.
- attributesToIndex: (array of strings) the list of fields you want to index.
If set to null, all textual and numerical attributes of your objects are indexed, but you should update it to get optimal results.
This parameter has two important uses:
- Limit the attributes to index: For example if you store a binary image in base64, you want to store it and be able to
retrieve it but you don't want to search in the base64 string.
- Control part of the ranking*: (see the ranking parameter for full explanation) Matches in attributes at the beginning of
the list will be considered more important than matches in attributes further down the list.
In one attribute, matching text at the beginning of the attribute will be considered more important than text after, you can disable
this behavior if you add your attribute inside `unordered(AttributeName)`, for example attributesToIndex: ["title", "unordered(text)"].
- attributesForFaceting: (array of strings) The list of fields you want to use for faceting.
All strings in the attribute selected for faceting are extracted and added as a facet. If set to null, no attribute is used for faceting.
- ranking: (array of strings) controls the way results are sorted.
We have six available criteria:
- typo: sort according to number of typos,
- geo: sort according to decreassing distance when performing a geo-location based search,
- proximity: sort according to the proximity of query words in hits,
- attribute: sort according to the order of attributes defined by attributesToIndex,
- exact: sort according to the number of words that are matched identical to query word (and not as a prefix),
- custom: sort according to a user defined formula set in **customRanking** attribute.
The standard order is ["typo", "geo", "proximity", "attribute", "exact", "custom"]
- customRanking: (array of strings) lets you specify part of the ranking.
The syntax of this condition is an array of strings containing attributes prefixed by asc (ascending order) or desc (descending order) operator.
For example `"customRanking" => ["desc(population)", "asc(name)"]`
- queryType: Select how the query words are interpreted, it can be one of the following value:
- prefixAll: all query words are interpreted as prefixes,
- prefixLast: only the last word is interpreted as a prefix (default behavior),
- prefixNone: no query word is interpreted as a prefix. This option is not recommended.
- highlightPreTag: (string) Specify the string that is inserted before the highlighted parts in the query result (default to "").
- highlightPostTag: (string) Specify the string that is inserted after the highlighted parts in the query result (default to "").
- optionalWords: (array of strings) Specify a list of words that should be considered as optional when found in the query.
AlgoliaException
public org.json.JSONObject listUserKeys() throws AlgoliaException
AlgoliaException
public org.json.JSONObject getUserKeyACL(String key) throws AlgoliaException
AlgoliaException
public org.json.JSONObject deleteUserKey(String key) throws AlgoliaException
AlgoliaException
public org.json.JSONObject addUserKey(List<String> acls) throws AlgoliaException
acls
- the list of ACL for this key. Defined by an array of strings that
can contains the following values:
- search: allow to search (https and http)
- addObject: allows to add/update an object in the index (https only)
- deleteObject : allows to delete an existing object (https only)
- deleteIndex : allows to delete index content (https only)
- settings : allows to get index settings (https only)
- editSettings : allows to change index settings (https only)
AlgoliaException
public org.json.JSONObject updateUserKey(String key, List<String> acls) throws AlgoliaException
acls
- the list of ACL for this key. Defined by an array of strings that
can contains the following values:
- search: allow to search (https and http)
- addObject: allows to add/update an object in the index (https only)
- deleteObject : allows to delete an existing object (https only)
- deleteIndex : allows to delete index content (https only)
- settings : allows to get index settings (https only)
- editSettings : allows to change index settings (https only)
AlgoliaException
public org.json.JSONObject addUserKey(List<String> acls, int validity, int maxQueriesPerIPPerHour, int maxHitsPerQuery) throws AlgoliaException
acls
- the list of ACL for this key. Defined by an array of strings that
can contains the following values:
- search: allow to search (https and http)
- addObject: allows to add/update an object in the index (https only)
- deleteObject : allows to delete an existing object (https only)
- deleteIndex : allows to delete index content (https only)
- settings : allows to get index settings (https only)
- editSettings : allows to change index settings (https only)validity
- the number of seconds after which the key will be automatically removed (0 means no time limit for this key)maxQueriesPerIPPerHour
- Specify the maximum number of API calls allowed from an IP address per hour. Defaults to 0 (no rate limit).maxHitsPerQuery
- Specify the maximum number of hits this API key can retrieve in one call. Defaults to 0 (unlimited)
AlgoliaException
public org.json.JSONObject updateUserKey(String key, List<String> acls, int validity, int maxQueriesPerIPPerHour, int maxHitsPerQuery) throws AlgoliaException
acls
- the list of ACL for this key. Defined by an array of strings that
can contains the following values:
- search: allow to search (https and http)
- addObject: allows to add/update an object in the index (https only)
- deleteObject : allows to delete an existing object (https only)
- deleteIndex : allows to delete index content (https only)
- settings : allows to get index settings (https only)
- editSettings : allows to change index settings (https only)validity
- the number of seconds after which the key will be automatically removed (0 means no time limit for this key)maxQueriesPerIPPerHour
- Specify the maximum number of API calls allowed from an IP address per hour. Defaults to 0 (no rate limit).maxHitsPerQuery
- Specify the maximum number of hits this API key can retrieve in one call. Defaults to 0 (unlimited)
AlgoliaException
public org.json.JSONObject searchDisjunctiveFaceting(Query query, List<String> disjunctiveFacets, Map<String,List<String>> refinements) throws AlgoliaException
query
- the querydisjunctiveFacets
- the array of disjunctive facetsrefinements
- MapAlgoliaException
public org.json.JSONObject searchDisjunctiveFaceting(Query query, List<String> disjunctiveFacets) throws AlgoliaException
AlgoliaException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |