Skip to content

Instantly share code, notes, and snippets.

@SupermanScott
Created February 12, 2012 23:32
Show Gist options
  • Save SupermanScott/1811838 to your computer and use it in GitHub Desktop.
Save SupermanScott/1811838 to your computer and use it in GitHub Desktop.
total = self.document_storage.count()
scope = dict(total=total)
results = self.collection.map_reduce(
map_function,
reduce_function,
finalize=finalize_function,
scope=scope,
query={'term': { '$in': list(terms)}},
out=bson.son.SON(dict(inline=1)))
scored_results = sorted(
results['results'],
key=lambda x: x['value'],
reverse=True)[offset:limit]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment