Note: This will return an array of objects for all objects found;
for those not found, it will return a null.
Retrieve only one object
Copy
1
2
3
4
5
6
7
// Retrieves all attributes$index->getObject('myId');// Retrieves only firstname and lastname attributes$index->getObject('myId',['attributeToRetrieve'=>['firstname','lastname'],]);
1
2
3
4
5
6
# Retrieves all attributesindex.get_object('myId')# Retrieves firstname and lastname attributesres=index.get_object('myId',['firstname','lastname'])# Retrieves only the firstname attributeres=index.get_object('myId',['firstname'])
1
2
3
4
5
6
7
8
9
10
11
// Retrieves all attributesindex.getObject('myId').then(object=>{console.log(object);});// Retrieves only firstname and lastname attributesindex.getObject('myId',{attributesToRetrieve:['firstname','lastname']}).then(object=>{console.log(object);});
1
2
3
4
5
6
7
8
9
10
11
12
# Retrieves all attributes
index.get_object('myId')# Retrieves firstname and lastname attributes
index.get_object('myId',{'attributesToRetrieve':['firstname, lastname']})# Retrieves only the firstname attribute
index.get_object('myId',{'attributesToRetrieve':['firstname']})
structContact:Codable{letfirstname:Stringletlastname:String?}// Retrieve all attributes.index.getObject(withID:"myId"){(result:Result<Contact,Error>)inifcase.success(letresponse)=result{print("Response: \(response)")}}// Retrieves `firstname` and `lastname` attributes.index.getObject(withID:"myId",attributesToRetrieve:["firstname","lastname"]){(result:Result<Contact,Error>)inifcase.success(letresponse)=result{print("Response: \(response)")}}// Retrieve only the `firstname` attribute.index.getObject(withID:"myId",attributesToRetrieve:["firstname"]){(result:Result<Contact,Error>)inifcase.success(letresponse)=result{print("Response: \(response)")}}
// Retrieves all attributesindex.getObjectAsync("myId",newCompletionHandler(){@OverridepublicvoidrequestCompleted(JSONObjectcontent,AlgoliaExceptionerror){// [...]}});// Retrieves the firstname and lastname attributeindex.getObjectAsync("myId",Arrays.asList("firstname","lastname"),newCompletionHandler(){@OverridepublicvoidrequestCompleted(JSONObjectcontent,AlgoliaExceptionerror){// [...]}});// Retrieves only the firstname attributeindex.getObjectAsync("myId",Arrays.asList("firstname"),newCompletionHandler(){@OverridepublicvoidrequestCompleted(JSONObjectcontent,AlgoliaExceptionerror){// [...]}});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Retrieves all attributesContactres=index.GetObject<Contact>("myId");// AsynchronousContactres=awaitindex.GetObjectAsync<Contact>("myId");// Retrieves firstname and lastname attributesContactres=index.GetObject<Contact>("myId",attributesToRetrieve:newList<string>{"firstname","lastname"});// AsynchronousContactres=awaitindex.GetObjectAsync<Contact>("myId",attributesToRetrieve:newList<string>{"firstname","lastname"});// Retrieves only the firstname attributeContactres=index.GetObject<Contact>("myId",attributesToRetrieve:newList<string>{"firstname"});// AsynchronousContactres=awaitindex.GetObjectAsync<Contact>("myId",attributesToRetrieve:newList<string>{"firstname"});
// Retrieves all attributesContactcontact=index.getObject("myId");// Async version// CompletableFuture<Contact> contact =index.getObject("myId");// Retrieves firstname and lastname attributesContactcontact=index.getObject("myId",Arrays.asList("firstname","lastname"));// Async version// CompletableFuture<Contact> contact =index.getObject("myId",Arrays.asList("firstname","lastname"));// Retrieves only the firstname attributeContactcontact=index.getObject("myId",Arrays.asList("firstname"));// Async version// CompletableFuture<Contact> contact =index.getObject("myId",Arrays.asList("firstname"));
1
2
3
4
5
6
7
8
// Retrieves the object with all its attributeserr:=index.GetObject("myId",&object)// Retrieves the object with only its `firstname` attributeerr:=index.GetObject("myId",&object,opt.AttributesToRetrieve("firstname"))// Retrieves the object with only its `firstname` and `lastname` attributeserr:=index.GetObject("myId",&object,opt.AttributesToRetrieve("firstname","lastname"))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Retrieves all attributesclient.execute{getfrom"index"objectId"myId"}// Retrieves firstname and lastname attributesclient.execute{getfrom"index"objectId"myId"attributesToRetrieveSeq("firstname","lastname")}// Retrieves only the firstname attributeclient.execute{getfrom"index"objectId"myId"attributesToRetrieveSeq("firstname")}
In this section we document the JSON response returned by the API.
Each language will encapsulate this response inside objects specific to the language and/or the implementation.
So the actual type in your language might differ from what is documented.
Here is an example where we try to get two objects.
The first one doesn’t exist (null is returned) but the second one does
(the object is returned).
If an object does not exist, null will be return instead.
Copy
1
2
3
4
5
6
7
8
9
10
{"results":[null,{"objectID":"1182729442","name":"product 1"}],"message":"ObjectID 1182729441 does not exist."}