예제 #1
0
파일: ess.py 프로젝트: weinix/metrilyx-2.0
 def __init__(self, config):
     super(ElasticsearchEventDataProvider, self).__init__(config)
     self.queryBuilder = ElasticsearchAnnotationQueryBuilder(**config)
     self.ds = Elasticsearch([{
         'host': self.host,
         'port': self.port,
         'use_ssl': self.use_ssl
     }])
예제 #2
0
파일: ess.py 프로젝트: weinix/metrilyx-2.0
class ElasticsearchEventDataProvider(BaseEventDataProvider):
    def __init__(self, config):
        super(ElasticsearchEventDataProvider, self).__init__(config)
        self.queryBuilder = ElasticsearchAnnotationQueryBuilder(**config)
        self.ds = Elasticsearch([{
            'host': self.host,
            'port': self.port,
            'use_ssl': self.use_ssl
        }])

    def add(self, item):
        '''
		used by django
		'''
        return self.ds.index(index=self.index,
                             doc_type=item['eventType'],
                             id=item['_id'],
                             body=item)

    def search(self, q):
        '''
		used by django
		'''
        return self.ds.search(index=self.index, body=q)

    def responseCallback(self, response):
        return [h['_source'] for h in response['hits']['hits']]

    def getQuery(self, request, split=True):
        for (url, eventType,
             query) in self.queryBuilder.getQuery(request, split):
            yield (url, "GET", query)
예제 #3
0
class ElasticsearchEventDataProvider(BaseEventDataProvider):
	def __init__(self, config):
		super(ElasticsearchEventDataProvider, self).__init__(config)
		self.queryBuilder = ElasticsearchAnnotationQueryBuilder(**config)
		self.ds = Elasticsearch([{
			'host': self.host,
			'port': self.port,
			'use_ssl': self.use_ssl
			}])

	def add(self, item):
		'''
		used by django
		'''
		return self.ds.index(index=self.index, 
				doc_type=item['eventType'], 
				id=item['_id'], 
				body=item)

	def search(self, q):
		'''
		used by django
		'''
		return self.ds.search(index=self.index, body=q)

	def responseCallback(self, response):
		return [ h['_source'] for h in response['hits']['hits'] ]


	def getQuery(self, request, split=True):
		for (url, eventType, query) in self.queryBuilder.getQuery(request, split):
			yield (url, "GET", query)
예제 #4
0
	def __init__(self, config):
		super(ElasticsearchEventDataProvider, self).__init__(config)
		self.queryBuilder = ElasticsearchAnnotationQueryBuilder(**config)
		self.ds = Elasticsearch([{
			'host': self.host,
			'port': self.port,
			'use_ssl': self.use_ssl
			}])