コード例 #1
0
 def status(self, index_name, extended=False):
     try:
         url = '%s/_status' % index_name
         res = json.loads(self._connection.get(url).content)
     except (requests.RequestException, urllib2.HTTPError), e:
         msg = 'Error Fetching Index Status - %s' % (e)
         raise exceptions.ActionIndexError(msg)
コード例 #2
0
 def close(self, index_name):
     try:
         url = '%s/_close' % index_name
         self._connection.post(url)
     except (requests.RequestException, urllib2.HTTPError), e:
         msg = 'Error Closing Index - %s' % (e)
         raise exceptions.ActionIndexError(msg)
コード例 #3
0
 def list(self, extended=False):
     try:
         health = self._connection.health
         state = self._connection.state
     except (requests.RequestException, urllib2.HTTPError), e:
         msg = 'Error Listing Indexes - %s' % (e)
         raise exceptions.ActionIndexError(msg)
コード例 #4
0
 def create(self, index_name, shards, replicas):
     try:
         data = {
             "settings": {
                 "number_of_shards": shards,
                 "number_of_replicas": replicas
             }
         }
         self._connection.post(index_name, data)
     except (requests.RequestException, urllib2.HTTPError), e:
         msg = 'Error Creating Index - %s' % (e)
         raise exceptions.ActionIndexError(msg)
コード例 #5
0
 def delete(self, index_name):
     try:
         self._connection.delete(index_name)
     except (requests.RequestException, urllib2.HTTPError), e:
         msg = 'Error Deleting Index - %s' % (e)
         raise exceptions.ActionIndexError(msg)