Skip to content

[BUG] Asynchronous searching does not work with wildcard indexes. (double escape) #319

@phallstrom

Description

@phallstrom

What is the bug?

Calling asynchronous_search.search and passing an index that has a wildcard (ie. index: "test-*") results in the error index_not_found_exception with reason: no such index [test-%2A]

How can one reproduce the bug?

@client.indices.create(index: "test-one")
@client.indices.create(index: "test-two")
@client.asynchronous_search.search(index: "test-*")

A full request/response cycle:

> @client.indices.create(index: "test-one")
-- PUT https://admin:***********@opensearch:9200/test-one [status:200, request:0.111s, query:n/a]
-- < {"acknowledged":true,"shards_acknowledged":true,"index":"test-one"}
=> {"acknowledged" => true, "shards_acknowledged" => true, "index" => "test-one"}

> @client.indices.create(index: "test-two")
-- PUT https://admin:***********@opensearch:9200/test-two [status:200, request:0.039s, query:n/a]
-- < {"acknowledged":true,"shards_acknowledged":true,"index":"test-two"}
=> {"acknowledged" => true, "shards_acknowledged" => true, "index" => "test-two"}

> @client.asynchronous_search.search(index: "test-*")
-- POST https://admin:***********@opensearch:9200/_plugins/_asynchronous_search?index=test-%252A [status:200, request:0.004s, query:n/a]
-- < {"id":"FlJJQjA4cUpzU0Yycl9PVUVDUEZIX2cGODQxMTk5FERCdmNiNW9CeVhFWkxsWm80aldOBDMzNjM=","state":"CLOSED","start_time_in_millis":1762813338253,"expiration_time_in_millis":1762899738253,"error":{"type":"index_not_found_exception","reason":"no such index [test-%2A]","index":"test-%2A","resource.id":"test-%2A","resource.type":"index_or_alias","index_uuid":"_na_"}}
=>
{"id" => "FlJJQjA4cUpzU0Yycl9PVUVDUEZIX2cGODQxMTk5FERCdmNiNW9CeVhFWkxsWm80aldOBDMzNjM=",
 "state" => "CLOSED",
 "start_time_in_millis" => 1762813338253,
 "expiration_time_in_millis" => 1762899738253,
 "error" => {"type" => "index_not_found_exception", "reason" => "no such index [test-%2A]",
             "index" => "test-%2A", "resource.id" => "test-%2A", "resource.type" => "index_or_alias",
             "index_uuid" => "_na_"}}

What is the expected behavior?

I would expect the search to succeed and search all indices matching test-*.

What is your host/environment?

Alpine Linux
Linux api 6.10.14-linuxkit #1 SMP Tue Oct 14 07:32:13 UTC 2025 aarch64 Linux

Do you have any additional context?

The problem is that the query parameters are being escaped twice. Once in the async-search code and once in the underlying transport.
https://github.com/opensearch-project/opensearch-ruby/blob/main/lib/opensearch/api/actions/asynchronous_search/search.rb#L24
https://github.com/opensearch-project/opensearch-ruby/blob/main/lib/opensearch/transport/transport/connections/connection.rb#L79

As far as I can tell, async-search is the only endpoint that passes the index on the query string. All of the others either pass it in the body or build it into the URL itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions