# Unable to change query paramters in rally

**URL:** <https://discuss.elastic.co/t/unable-to-change-query-paramters-in-rally/313711>\
**Category:** Elasticsearch\
**Tags:** rally\
**Created:** [September 5, 2022, 6:57pm UTC](https://discuss.elastic.co/t/unable-to-change-query-paramters-in-rally/313711 "2022-09-05T18:57:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmlucjav](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jmlucjav/32/5870_2.png) [@jmlucjav](https://discuss.elastic.co/u/jmlucjav)\
**Post date:** [September 5, 2022, 6:57pm UTC](https://discuss.elastic.co/t/unable-to-change-query-paramters-in-rally/313711/1 "2022-09-05T18:57:33Z")

</div>

Hi there,

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

```auto
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

---

<div class="post-metadata">

**Author:** ![Bradley\_Deam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bradley_deam/32/52991_2.png) [@Bradley\_Deam](https://discuss.elastic.co/u/Bradley_Deam)\
**Post date:** [September 6, 2022, 12:51am UTC](https://discuss.elastic.co/t/unable-to-change-query-paramters-in-rally/313711/2 "2022-09-06T00:51:16Z")

</div>

Hi @jmlucjav!

Seems like a silly question, but have you 'registered' your custom param source? [In the docs](https://esrally.readthedocs.io/en/stable/adding_tracks.html?highlight=Custom%20paramsource#custom-parameter-sources) we include an example like below;

```auto
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;

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

```

---

<div class="post-metadata">

**Author:** ![jmlucjav](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jmlucjav/32/5870_2.png) [@jmlucjav](https://discuss.elastic.co/u/jmlucjav)\
**Post date:** [September 6, 2022, 7:02am UTC](https://discuss.elastic.co/t/unable-to-change-query-paramters-in-rally/313711/3 "2022-09-06T07:02:14Z")

</div>

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](https://www.elastic.co/guide/en/elasticsearch/reference/8.4/search-search.html#search-search-api-query-params) params (in my case preference and request\_cache).

I have been looking into rally code [rally/runner.py at master · elastic/rally · GitHub](https://github.com/elastic/rally/blob/master/esrally/driver/runner.py#L864) and I was hoping this would make the trick:

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

```

But no luck, request\_cache is still not used...

thanks!

---

<div class="post-metadata">

**Author:** ![dliappis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dliappis/32/56174_2.png) [@dliappis](https://discuss.elastic.co/u/dliappis)\
**Post date:** [September 6, 2022, 12:07pm UTC](https://discuss.elastic.co/t/unable-to-change-query-paramters-in-rally/313711/4 "2022-09-06T12:07:42Z")

</div>

> [@jmlucjav](#):
>
> But no luck, request\_cache is still not used...

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](https://esrally.readthedocs.io/en/stable/adding_tracks.html?highlight=parameter%20source#custom-parameter-sources)

Did you try debugging using the instructions in [Tips and Tricks - Rally 2.10.0 documentation](https://esrally.readthedocs.io/en/stable/recipes.html#checking-queries-and-responses), to verify what exactly Rally ends up sending to Elasticsearch?

---

<div class="post-metadata">

**Author:** ![jmlucjav](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jmlucjav/32/5870_2.png) [@jmlucjav](https://discuss.elastic.co/u/jmlucjav)\
**Post date:** [September 6, 2022, 7:56pm UTC](https://discuss.elastic.co/t/unable-to-change-query-paramters-in-rally/313711/5 "2022-09-06T19:56:49Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![RickBoyd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rickboyd/32/80022_2.png) [@RickBoyd](https://discuss.elastic.co/u/RickBoyd)\
**Post date:** [September 6, 2022, 8:15pm UTC](https://discuss.elastic.co/t/unable-to-change-query-paramters-in-rally/313711/6 "2022-09-06T20:15:01Z")

</div>

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](https://esrally.readthedocs.io/en/stable/track.html#id6). You would nest any other parameters you want from the Search API in the value of `"request-params"`, e.g.

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

---

<div class="post-metadata">

**Author:** ![jmlucjav](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jmlucjav/32/5870_2.png) [@jmlucjav](https://discuss.elastic.co/u/jmlucjav)\
**Post date:** [September 7, 2022, 12:47pm UTC](https://discuss.elastic.co/t/unable-to-change-query-paramters-in-rally/313711/7 "2022-09-07T12:47:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 5, 2022, 12:48pm UTC](https://discuss.elastic.co/t/unable-to-change-query-paramters-in-rally/313711/8 "2022-10-05T12:48:01Z")

</div>

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