Permalink
Browse files

add format option to respond by sdk format

aws-sdk for ruby use 'sdk' format
  • Loading branch information...
1 parent 796b9fa commit c66bda560fbbfb124e5a3cb49d70b67a7d5bee55 @hokuma committed Sep 25, 2016
Showing with 6 additions and 0 deletions.
  1. +6 −0 nozama-cloudsearch-data/nozama/cloudsearch/data/document.py
@@ -125,6 +125,8 @@ def search(query={}):
qstring = query.get('q', '')
log.debug("searching query '{0}'".format(query))
+ response_format = query.get('format', '')
+ log.debug("response format '{0}'".format(response_format))
try:
if qstring:
@@ -154,6 +156,10 @@ def search(query={}):
for i in results['hits']['hits']:
query = dict(_id=i['_id'])
fields = conn.documents.find_one(query)['fields']
+ if response_format == u'sdk':
+ for key, value in fields.items():
+ if not isinstance(value, list):
+ fields[key] = [value]
hit.append({"id": i['_id'], "fields": fields})
rc = {

0 comments on commit c66bda5

Please sign in to comment.