code: def _search_metrics_and_metadata(self, metadata_endpoint, query,
                                       order_by=None, offset=None,
                                       limit=None, timeout=None):
          
          _logger.debug('Performing an elasticsearch for %(qry)s at %(pt)s',
                        {'qry': query, 'pt': metadata_endpoint})
          url_to_get = '{0}?query={1}'.format(self._u(metadata_endpoint), query)
          if order_by is not None:
              url_to_get += '&orderBy=' + order_by
          # for offset and limit, use API defaults (by leaving them out of url)
          if offset is not None:
              url_to_get += '&offset=' + str(offset)
          if limit is not None:
              url_to_get += '&limit=' + str(limit)
          timeout = timeout or self._timeout
          resp = self._get(url_to_get, session=self._session, timeout=timeout)
          resp.raise_for_status()
          return resp.json()
docs: generic function for elasticsearch queries; can search metrics,
              dimensions, metrictimeseries by changing metadata_endpoint
          Args:
              metadata_endpoint (string): API endpoint suffix (e.g. 'v2/metric')
              query (string): elasticsearch string query
              order_by (optional[string]): property by which to order results
              offset (optional[int]): number of results to skip for pagination
                  (default=0)
              limit (optional[int]): how many results to return (default=50)
              timeout (optional[int]): how long to wait for response (in seconds)
  
          Returns:
              dictionary of query result