How to use the esrally.track.track.Query function in esrally

To help you get started, we’ve selected a few esrally examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github elastic / rally / esrally / track / percolator_track.py View on Github external
"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": {
github elastic / rally / esrally / track / logging_track.py View on Github external
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"
      }
    }
  }
}''')
github elastic / rally / esrally / track / geopoint_track.py View on Github external
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):
github elastic / rally / esrally / track / pmc_track.py View on Github external
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):
github elastic / rally / esrally / track / geopoint_track.py View on Github external
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" : {
github elastic / rally / esrally / track / pmc_track.py View on Github external
def __init__(self):
        track.Query.__init__(self, "default")
github elastic / rally / esrally / track / geonames_track.py View on Github external
def __init__(self):
        track.Query.__init__(self, "default")
github elastic / rally / esrally / track / geonames_track.py View on Github external
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": {
github elastic / rally / esrally / track / geopoint_track.py View on Github external
def __init__(self):
        track.Query.__init__(self, "default")
github elastic / rally / esrally / track / geopoint_track.py View on Github external
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]
        }
      }
    }''')