text
stringlengths 0
828
|
|---|
max_bytes: int
|
Maximum number of bytes to read.
|
Raises
|
------
|
ValueError
|
If read is called after close has been called.
|
Returns
|
--------
|
bytes
|
Bytes extracted from internal buffer. Length may be less
|
than `max_bytes`. On end-of file returns a bytes object
|
with zero-length.
|
""""""
|
if self.__num_bytes_consumed is None:
|
raise ValueError('I/O operation on closed file.')
|
if self.__num_bytes_consumed + max_bytes >= len(self.__buf):
|
max_bytes = len(self.__buf) - self.__num_bytes_consumed
|
b = self.__buf[self.__num_bytes_consumed:self.__num_bytes_consumed + max_bytes]
|
self.__num_bytes_consumed += max_bytes
|
if isinstance(b, bytearray):
|
b = bytes(b)
|
assert isinstance(b, bytes)
|
return b"
|
645,"def timeout(self, value):
|
'''
|
Specifies a timeout on the search query
|
'''
|
if not self.params:
|
self.params = dict(timeout=value)
|
return self
|
self.params['timeout'] = value
|
return self"
|
646,"def filtered(self, efilter):
|
'''
|
Applies a filter to the search
|
'''
|
if not self.params:
|
self.params={'filter' : efilter}
|
return self
|
if not self.params.has_key('filter'):
|
self.params['filter'] = efilter
|
return self
|
self.params['filter'].update(efilter)
|
return self"
|
647,"def size(self,value):
|
'''
|
The number of hits to return. Defaults to 10
|
'''
|
if not self.params:
|
self.params = dict(size=value)
|
return self
|
self.params['size'] = value
|
return self"
|
648,"def from_offset(self, value):
|
'''
|
The starting from index of the hits to return. Defaults to 0.
|
'''
|
if not self.params:
|
self.params = dict({'from':value})
|
return self
|
self.params['from'] = value
|
return self"
|
649,"def sort(self, *args, **kwargs):
|
'''
|
http://www.elasticsearch.org/guide/reference/api/search/sort.html
|
Allows to add one or more sort on specific fields. Each sort can be reversed as well. The sort is defined on a per field level, with special field name for _score to sort by score.
|
standard arguments are ordered ascending, keyword arguments are fields and you specify the order either asc or desc
|
'''
|
if not self.params:
|
self.params = dict()
|
self.params['sort'] = list()
|
for arg in args:
|
self.params['sort'].append(arg)
|
for k,v in kwargs.iteritems():
|
self.params['sort'].append({k : v})
|
return self"
|
650,"def sorted(self, fsort):
|
'''
|
Allows to add one or more sort on specific fields. Each sort can be reversed as well. The sort is defined on a per field level, with special field name for _score to sort by score.
|
'''
|
if not self.params:
|
self.params = dict()
|
self.params['sort'] = fsort
|
return self"
|
651,"def search_simple(self, index,itype, key, search_term):
|
'''
|
ElasticSearch.search_simple(index,itype,key,search_term)
|
Usage:
|
> es = ElasticSearch()
|
> es.search_simple('twitter','users','name','kim')
|
'''
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.