text
stringlengths
0
828
request = self.session
url = 'http://%s:%s/%s/%s/_search?q=%s:%s' % (self.host,self.port,index,itype,key,search_term)
response = request.get(url)
return response"
652,"def search_advanced(self, index, itype, query):
'''
Advanced search interface using specified query
> query = ElasticQuery().term(user='kimchy')
> ElasticSearch().search_advanced('twitter','posts',query)
... Search results ...
'''
request = self.session
url = 'http://%s:%s/%s/%s/_search' % (self.host,self.port,index,itype)
if self.params:
query_header = dict(query=query, **self.params)
else:
query_header = dict(query=query)
if self.verbose:
print query_header
response = request.post(url,query_header)
return response"
653,"def doc_create(self,index,itype,value):
'''
Creates a document
'''
request = self.session
url = 'http://%s:%s/%s/%s/' % (self.host, self.port, index, itype)
if self.verbose:
print value
response = request.post(url,value)
return response"
654,"def search_index_simple(self,index,key,search_term):
'''
Search the index using a simple key and search_term
@param index Name of the index
@param key Search Key
@param search_term The term to be searched for
'''
request = self.session
url = 'http://%s:%s/%s/_search?q=%s:%s' % (self.host,self.port,index,key,search_term)
response = request.get(url)
return response"
655,"def search_index_advanced(self, index, query):
'''
Advanced search query against an entire index
> query = ElasticQuery().query_string(query='imchi')
> search = ElasticSearch()
'''
request = self.session
url = 'http://%s:%s/%s/_search' % (self.host, self.port, index)
if self.params:
content = dict(query=query, **self.params)
else:
content = dict(query=query)
if self.verbose:
print content
response = request.post(url,content)
return response"
656,"def index_create(self, index, number_of_shards=5,number_of_replicas=1):
'''
Creates the specified index
> search = ElasticSearch()
> search.index_create('twitter')
{""ok"":true,""acknowledged"":true}
'''
request = self.session
content = {'settings' : dict(number_of_shards=number_of_shards, number_of_replicas=number_of_replicas)}
if self.verbose:
print content
url = 'http://%s:%s/%s' % (self.host, self.port, index)
response = request.put(url,content)
return response"
657,"def index_delete(self, index):
'''
Delets the specified index
> search = ElasticSearch()
> search.index_delete('twitter')
{""ok"" : True, ""acknowledged"" : True }
'''
request = self.session
url = 'http://%s:%s/%s' % (self.host, self.port, index)
response = request.delete(url)
return response"
658,"def index_open(self, index):
'''
Opens the speicified index.
http://www.elasticsearch.org/guide/reference/api/admin-indices-open-close.html
> ElasticSearch().index_open('my_index')
'''
request = self.session
url = 'http://%s:%s/%s/_open' % (self.host, self.port, index)
response = request.post(url,None)
return response"
659,"def river_couchdb_create(self, index_name,index_type='',couchdb_db='', river_name='',couchdb_host='localhost', couchdb_port='5984',couchdb_user=None, couchdb_password=None, couchdb_filter=None,script=''):
'''