Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"constant_score": {
"query": {
"percolate" : {
"field" : "query",
"document_type" : "content",
"document" : {
"body" : "%s"
}
}
}
}
}
}''' % self.content)
class PercolatorQueryWithHighlighting(track.Query):
def __init__(self):
track.Query.__init__(self, "percolator query with highlighting")
def run(self, es):
return es.search(index=PERCOLATOR_INDEX_NAME, doc_type=PERCOLATOR_TYPE_NAME, body='''
{
"query": {
"percolate" : {
"field" : "query",
"document_type" : "content",
"document" : {
"body" : "Israeli prime minister Ariel Sharon suffers a massive stroke; he is replaced by acting prime minister Ehud Olmert"
}
}
},
"highlight": {
return es.search(index=LOGGING_INDEX_PATTERN, doc_type=LOGGING_TYPE_NAME, body='''
{
"query": {
"range": {
"@timestamp": {
"gte": "now-%dd/d",
"lt": "now/d"
}
}
}
}
''' % self.diff_days)
# TODO dm: Turn off request cache?
class HourlyAggQuery(track.Query):
def __init__(self):
track.Query.__init__(self, "hourly_agg")
def run(self, es):
return es.search(index=LOGGING_INDEX_PATTERN, doc_type=LOGGING_TYPE_NAME, body='''
{
"size": 0,
"aggs": {
"by_hour": {
"date_histogram": {
"field": "@timestamp",
"interval": "hour"
}
}
}
}''')
def run(self, es):
return es.search(index=GEO_POINT_INDEX_NAME, doc_type=GEO_POINT_TYPE_NAME, body='''
{
"query" : {
"geo_bounding_box" : {
"location" : {
"top_left" : [-0.1, 61.0],
"bottom_right" : [15.0, 48.0]
}
}
}
}''')
class DistanceQuery(track.Query):
def __init__(self):
track.Query.__init__(self, "distance")
def run(self, es):
return es.search(index=GEO_POINT_INDEX_NAME, doc_type=GEO_POINT_TYPE_NAME, body='''
{
"query" : {
"geo_distance" : {
"distance" : "200km",
"location" : [7.0, 55.0]
}
}
}''')
class DistanceRangeQuery(track.Query):
def __init__(self):
track.Query.__init__(self, "default")
def run(self, es):
return es.search(index=PMC_INDEX_NAME)
class TermQuery(track.Query):
def __init__(self):
track.Query.__init__(self, "term")
def run(self, es):
return es.search(index=PMC_INDEX_NAME, doc_type=PMC_TYPE_NAME, q="body:physician")
class PhraseQuery(track.Query):
def __init__(self):
track.Query.__init__(self, "phrase")
def run(self, es):
return es.search(index=PMC_INDEX_NAME, doc_type=PMC_TYPE_NAME, body='''
{
"query": {
"match_phrase": {
"body": "newspaper coverage"
}
}
}''')
class MonthlyArticlesAggQuery(track.Query):
def __init__(self, suffix="", use_request_cache=True):
from esrally.track import track
GEO_POINT_INDEX_NAME = "osmgeopoints"
GEO_POINT_TYPE_NAME = "type"
class DefaultQuery(track.Query):
def __init__(self):
track.Query.__init__(self, "default")
def run(self, es):
return es.search(index=GEO_POINT_INDEX_NAME)
class BBoxQuery(track.Query):
def __init__(self):
track.Query.__init__(self, "bbox")
def run(self, es):
return es.search(index=GEO_POINT_INDEX_NAME, doc_type=GEO_POINT_TYPE_NAME, body='''
{
"query" : {
"geo_bounding_box" : {
def __init__(self):
track.Query.__init__(self, "default")
def __init__(self):
track.Query.__init__(self, "default")
class PhraseQuery(track.Query):
def __init__(self):
track.Query.__init__(self, "phrase")
def run(self, es):
return es.search(index=GEO_NAMES_INDEX_NAME, doc_type=GEO_NAMES_TYPE_NAME, body='''
{
"query": {
"match_phrase": {
"name": "Sankt Georgen"
}
}
}''')
class CountryAggQuery(track.Query):
def __init__(self, suffix="", use_request_cache=True):
track.Query.__init__(self, "country_agg" + suffix)
self.use_request_cache = use_request_cache
def run(self, es):
return es.search(index=GEO_NAMES_INDEX_NAME, doc_type=GEO_NAMES_TYPE_NAME,
request_cache=self.use_request_cache, body='''
{
"size": 0,
"aggs": {
"country_population": {
"terms": {
"field": "country_code"
},
"aggs": {
"sum_population": {
def __init__(self):
track.Query.__init__(self, "default")
def __init__(self):
track.Query.__init__(self, "distance")
def run(self, es):
return es.search(index=GEO_POINT_INDEX_NAME, doc_type=GEO_POINT_TYPE_NAME, body='''
{
"query" : {
"geo_distance" : {
"distance" : "200km",
"location" : [7.0, 55.0]
}
}
}''')
class DistanceRangeQuery(track.Query):
def __init__(self):
track.Query.__init__(self, "distanceRange")
def run(self, es):
return es.search(index=GEO_POINT_INDEX_NAME, doc_type=GEO_POINT_TYPE_NAME, body='''
{
"query" : {
"geo_distance_range" : {
"from" : "200km",
"to" : "400km",
"location" : [7.0, 55.0]
}
}
}''')