Ignore unrecognized query parameters in the query payload

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
“number”: “2.13.0”

Describe the issue:
I need to send some custom parameters with the query payload and need OpenSearch to ignore them instead of failing the request with “unknown key” and parsing_exception.

I tried using “ignore_unrecognized” parameter that I found to be the param supportive of this but it still reports the same error.

Configuration:

GET web/_search
{
  "query": {
    "match": {
      "title": "hello world"
    }
  },
  "query_source": "mobile",
  "ignore_unrecognized": true
}

Relevant Logs or Screenshots:

{
  "error": {
    "root_cause": [
      {
        "type": "parsing_exception",
        "reason": "Unknown key for a VALUE_BOOLEAN in [ignore_unrecognized].",
        "line": 7,
        "col": 26
      }
    ],
    "type": "parsing_exception",
    "reason": "Unknown key for a VALUE_BOOLEAN in [ignore_unrecognized].",
    "line": 7,
    "col": 26
  },
  "status": 400
}

That error you’re seeing is because the ignore_unrecognized parameter is not valid. Out of curiosity, where did you find that documented, since we should fix it?

In general, OpenSearch doesn’t allow you to specify unrecognized properties anywhere in a request.

That said, there is an ext parameter for search requests, where the contents are expected to be parsed by plugins. I believe that if you add a value in an ext block that is not recognized, it will be ignored.

Thank you for looking into this one. The variable was suggested by chatgpt. Regarding ext parameter, I maybe missing something, I tried the following but the query parameters validation continues to happen.

GET web/_search
{
  "query": {
    "match_all": {}
  },
   "ext": {
       "lang" : "en"
   }
  
}
{
  "error": {
    "root_cause": [
      {
        "type": "named_object_not_found_exception",
        "reason": "[6:17] unknown field [lang]"
      }
    ],
    "type": "named_object_not_found_exception",
    "reason": "[6:17] unknown field [lang]"
  },
  "status": 400
}

Oh, dang! Okay… ext doesn’t let you add arbitrary parameters unless there’s a plugin registered to process the given parameters.

In that case, as far as I know, you can’t easily add unrecognized parameters without a validation error. If you’re running OpenSearch on your own cluster, you could develop a plugin that registers an ext parser (and maybe skips the content without doing anything with it). That would allow you to add arbitrary parameters.

I guess the other question is why you want/need to pass arbitrary parameters in your query payload. Maybe there’s a different solution to the underlying problem.