opensearch-project / opensearch-project/opensearch-ruby

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

Open
#319 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Ruby
Stars
114
Forks
60
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read lib/opensearch/api/actions/asynchronous_search/search.rb at line 24 and the transport handling in lib/opensearch/transport/transport/connections/connection.rb at line 79. Reproduce the wildcard request with indices named test-one and test-two, then trace where the index parameter is escaped. Done means asynchronous_search.search accepts test-* without turning the wildcard into test-%2A and searches the matching indices.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.