Skip to content

Instantly share code, notes, and snippets.

@btx
Created February 11, 2015 18:10
Show Gist options
  • Select an option

  • Save btx/2374c673284c01384225 to your computer and use it in GitHub Desktop.

Select an option

Save btx/2374c673284c01384225 to your computer and use it in GitHub Desktop.
s = Search()
s1 = s.doc_type('company').filter('term', _id=28557204)
s2 = s1.fields(['name'])
s1.to_dict()
# {'query': {'filtered': {'filter': {'term': {'_id': 28557204}}, 'query': {'match_all': {}}}}}
s2.to_dict()
# {'query': {'filtered': {'filter': {'term': {'_id': 28557204}}, 'query': {'match_all': {}}}}, 'fields': ['name']}
s1.execute().hits[0].name
# u'Loutkov\xe9 divadlo Maminy o.s.'
s2.execute().hits[0].name
# [u'Loutkov\xe9 divadlo Maminy o.s.']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment