Unable to change query paramters in rally

Hi there,

I am generating my own queries for a benchmark, my py code looks like this (adapted from some github repos I found):

class QueryParamSource:
    def __init__(self, track, params, **kwargs):
       ...
    def partition(self, partition_index, total_partitions):
        ...
        return self

class ListingQueryParamSource(QueryParamSource):
    def params(self):
        ...
        result = {
            "body": qbody,
            "index": index_name,
             "preference": '_local',
            "invalid_param": 'invalid_Value',
            "request_cache": 'true'
        }
        return result

I wanted to change some search request query params like 'preference', 'request_cache' etc. I thought adding them to the result dict would work.

But my benchmark numbers were not affected, so I was suspicious they are affecting the options I need, so I tried some invalid param (named invalid_param) and the benchmark run happily, so I guess this is not the way to change query parameters.

Is there a way to change them, if so, how?

Thank you guys

Hi @jmlucjav!

Seems like a silly question, but have you 'registered' your custom param source? In the docs we include an example like below;

class TermParamSource:
    def __init__(self, track, params, **kwargs):
        return [...]

    def partition(self, partition_index, total_partitions):
        return [...]

    def params(self):
        return [...]

def register(registry):
    registry.register_param_source("my-custom-term-param-source", TermParamSource)

And then in your track.json you'd use the registered param source like so;

{
  "name": "term",
  "operation-type": "search",
  "param-source": "my-custom-term-param-source"
  "professions": ["mechanic", "physician", "nurse"],
  "index": "employee*",
  "type": "docs"
}

Hi Bradley,

Yes, sorry I omitted that for brevity, but I am registering and the source is running fine (barring this issue about the query params).

To be more clear: I want o set some of these Search API | Elasticsearch Guide [8.4] | Elastic params (in my case preference and request_cache).

I have been looking into rally code rally/runner.py at master · elastic/rally · GitHub and I was hoping this would make the trick:

        result = {
            "body": qbody,
            "index": index_name,
            "cache": 'true'
        }

But no luck, request_cache is still not used...

thanks!

At least the docs do show that for an operation-type search the customer parameter source (should) specify the cache: Define Custom Workloads: Tracks - Rally 2.10.0 documentation

Did you try debugging using the instructions in Tips and Tricks - Rally 2.10.0 documentation, to verify what exactly Rally ends up sending to Elasticsearch?

hi dliappis,

That helped a lot. I got logging configured, and that helped show some other underlying issue I had with some param not being passed all the way. I got caching working now.

thank you indeed!

Fantastic. As for the other things you'd like to try that are not top-level search parameters, see Track Reference - Rally 2.6.0 documentation. You would nest any other parameters you want from the Search API in the value of "request-params", e.g.

  ...
  return {
    "body": qbody,
    "index": index_name,
    "request-params": {
      "preference": "_local"
    }
  }

I confirm cache and request-params work nicely, thanks a bunch!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.