Skip to content

Commit

Permalink
Merge pull request #342 from algolia/fix/299
Browse files Browse the repository at this point in the history
Index::get_objects: Accept only list for attributes_to_retrieve
  • Loading branch information
julienbourdeau authored Mar 28, 2018
2 parents aea8c09 + 44c90ac commit e3acc63
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions algoliasearch/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,17 @@ def get_objects(self, object_ids, attributes_to_retrieve=None, request_options=N
Get several objects from this index.
@param object_ids the array of unique identifier of objects to retrieve
@param attributes_to_retrieve (optional) if set, contains the list
of attributes to retrieve as a string separated by a comma
@param attributes_to_retrieve (optional) list of attributes to retrieve
"""
requests = []
for object_id in object_ids:
request = {'indexName': self.index_name, 'objectID': object_id}
if attributes_to_retrieve is not None:

if isinstance(attributes_to_retrieve, list):
request['attributesToRetrieve'] = ",".join(attributes_to_retrieve)
elif attributes_to_retrieve is not None:
raise AlgoliaException('attributes_to_retrieve must be a list of attributes')

requests.append(request)
data = {'requests': requests}
path = '/1/indexes/*/objects' # Use client._req()
Expand Down

0 comments on commit e3acc63

Please sign in to comment.