Example #1
0
    def _default(self):
        ''' Load data into elasticsearch service

            Args:
                count (:obj:`int`): cursor size
                cursor (:obj:`pymongo.Cursor` or :obj:`iter`): documents to be PUT/POST to es
                index (:obj:`str`): name of unique key to be used as index for es
                bulk_size (:obj:`int`): number of documents in one PUT
                headers (:obj:`dict`): http header
                _id (:obj:`str`): key in mogno collection for identification

            Returns:
                (:obj:`set`): set of status codes
        '''
        args = self.app.pargs
        es_util.EsUtil(profile_name=args.profile_name,
                       credential_path=args.credential_path,
                       config_path=args.config_path,
                       elastic_path=args.elastic_path).data_to_es_bulk(
                           args.cursor,
                           index=args.index,
                           count=args.count,
                           bulk_size=args.bulk_size,
                           _id=args.id,
                           headers=args.headers)
Example #2
0
    def _default(self):
        ''' Delete elasticsearch index

            Args:
                index (:obj:`str`): name of index in es
                _id (:obj:`int`): id of the doc in index (optional)
        '''
        args = self.app.pargs
        es_util.EsUtil(profile_name=args.profile_name,
                       credential_path=args.credential_path,
                       config_path=args.config_path,
                       elastic_path=args.elastic_path).delete_index(
                           args.index, _id=args.id)
Example #3
0
    def _default(self):
        ''' Delete elasticsearch index

            Args:
                index (:obj:`str`): name of index in es
                _id (:obj:`int`): id of the doc in index (optional)
        '''
        args = self.app.pargs
        r = es_util.EsUtil(
            profile_name=args.profile_name,
            credential_path=args.credential_path,
            config_path=args.config_path,
            elastic_path=args.elastic_path).index_health_status()
        print(r.content.decode('utf-8'))
Example #4
0
    def _default(self):
        ''' Delete elasticsearch index

            Args:
                index (:obj:`str`): name of index in es
                _id (:obj:`int`): id of the doc in index (optional)
        '''
        args = self.app.pargs
        r = es_util.EsUtil(
            profile_name=args.profile_name,
            credential_path=args.credential_path,
            config_path=args.config_path,
            elastic_path=args.elastic_path).get_index_mapping(index=args.index)
        content = json.loads(r.content.decode('utf-8'))
        pprint.pprint(content)
Example #5
0
    def _default(self):
        """Setting index's shard and replica number in es cluster
        
        Args:
            index (str): name of index to be set
            number_of_replicas (int): number of replica shards to be used for the index
            number_of_shards (int): number of primary shards contained in the es cluster
            headers (dict): http request content header description

        Returns:
            (HTTPResponse): http response
        """
        args = self.app.pargs
        es_util.EsUtil(profile_name=args.profile_name,
                       credential_path=args.credential_path,
                       config_path=args.config_path,
                       elastic_path=args.elastic_path).update_index_analysis(
                           args.index, args.filter_dir, args.analyzer_dir)
 def setUpClass(cls):
     cls.cache_dir = tempfile.mkdtemp()
     cls.src = util.EsUtil(
         profile_name='es-poweruser',
         credential_path='~/.wc/third_party/aws_credentials',
         config_path='~/.wc/third_party/aws_config',
         elastic_path='~/.wc/third_party/elasticsearch.ini',
         cache_dir=cls.cache_dir,
         service_name='es',
         max_entries=float('inf'),
         verbose=True)
     cls.index = 'test'
     cls.index_0 = 'test_0'
     cls.index_1 = 'test_1'
     cls.index_2 = 'test_analysis'
     cls.url = cls.src.es_endpoint + '/' + cls.index
     cls.url_0 = cls.src.es_endpoint + '/' + cls.index_0
     cls.url_1 = cls.src.es_endpoint + '/' + cls.index_1
     cls.url_2 = cls.src.es_endpoint + '/' + cls.index_2
     requests.delete(cls.url, auth=cls.src.awsauth)