New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross-Cluster-Search with non-matching wildcard does local search instead #25426

Closed
tvernum opened this Issue Jun 27, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@tvernum
Contributor

tvernum commented Jun 27, 2017

Elasticsearch version: 5.5.0-SNAPSHOT
Plugins installed: None

Steps to reproduce:

A cross-cluster-search that has a remote wildcard that doesn't match anything, ends up running a local search across all indices.

That is: GET /my_remote:does_not_exist*/_search behaves like GET /_search

Reproduction:

# Start "local" cluster
$ bin/elasticsearch -Epath.data=./data.local -Epath.logs=logs.local -Ecluster.name=local -Etransport.tcp.port=9300 -Ehttp.port=9200 -d

# Start "remote" cluster
$ bin/elasticsearch -Epath.data=./data.remote -Epath.logs=logs.remote -Ecluster.name=remote -Etransport.tcp.port=9310 -Ehttp.port=9210 -d

# Put local index
$ curl -XPUT http://localhost:9200/test-index/doc/1 -d'{ "cluster": "local" }'
{"_index":"test-index","_type":"doc","_id":"1","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"created":true}

# Put remote index
$ curl -XPUT http://localhost:9210/remote-index/doc/1 -d'{ "cluster": "remote" }'
{"_index":"remote-index","_type":"doc","_id":"1","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"created":true}

# Put cluster seed
$ curl -XPUT 'http://localhost:9200/_cluster/settings?pretty' -H 'Content-Type: application/json' -d'
{
  "transient": {
    "search.remote.remote_cluster.seeds": "127.0.0.1:9310"
  }
}'
{
  "acknowledged" : true,
  "persistent" : { },
  "transient" : {
    "search" : {
      "remote" : {
        "remote_cluster" : {
          "seeds" : "127.0.0.1:9310"
        }
      }
    }
  }
}

# Search remote cluster, find remote index [correct]
$ curl 'http://localhost:9200/remote_cluster:*/_search'
{"took":152,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":1.0,"hits":[{"_index":"remote_cluster:remote-index","_type":"doc","_id":"1","_score":1.0,"_source":{ "cluster": "remote" }}]}}

# Search for non-existent index, get appropriate error [correct]
$ curl 'http://localhost:9200/remote_cluster:does_not_exist/_search'
{"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index","index_uuid":"_na_","resource.type":"index_or_alias","resource.id":"does_not_exist","index":"does_not_exist"}],"type":"transport_exception","reason":"unable to communicate with remote cluster [remote_cluster]","caused_by":{"type":"index_not_found_exception","reason":"no such index","index_uuid":"_na_","resource.type":"index_or_alias","resource.id":"does_not_exist","index":"does_not_exist"}},"status":500}

# Search for non-existent wildcard, find local documents [incorrect]
$ curl 'http://localhost:9200/remote_cluster:does_not_exist*/_search'
{"took":20,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":1.0,"hits":[{"_index":"test-index","_type":"doc","_id":"1","_score":1.0,"_source":{ "cluster": "local" }}]}}

jaymode added a commit to jaymode/elasticsearch that referenced this issue Jun 27, 2017

Do not search locally if remote index pattern resolves to no indices
This commit changes how we determine if there were any remote indices that a search should have
been executed against. Previously, we used the list of remote shard iterators but if the remote
index pattern resolved to no indices there would be no remote shard iterators even though the
request specified remote indices. The map of remote cluster names to the original indices is used
instead so that we can determine if there were remote indices even when there are no remote shard
iterators.

Closes elastic#25426

jaymode added a commit that referenced this issue Jun 28, 2017

Do not search locally if remote index pattern resolves to no indices (#…
…25436)

This commit changes how we determine if there were any remote indices that a search should have
been executed against. Previously, we used the list of remote shard iterators but if the remote
index pattern resolved to no indices there would be no remote shard iterators even though the
request specified remote indices. The map of remote cluster names to the original indices is used
instead so that we can determine if there were remote indices even when there are no remote shard
iterators.

Closes #25426

jaymode added a commit that referenced this issue Jun 28, 2017

Do not search locally if remote index pattern resolves to no indices (#…
…25436)

This commit changes how we determine if there were any remote indices that a search should have
been executed against. Previously, we used the list of remote shard iterators but if the remote
index pattern resolved to no indices there would be no remote shard iterators even though the
request specified remote indices. The map of remote cluster names to the original indices is used
instead so that we can determine if there were remote indices even when there are no remote shard
iterators.

Closes #25426

jaymode added a commit that referenced this issue Jun 28, 2017

Do not search locally if remote index pattern resolves to no indices (#…
…25436)

This commit changes how we determine if there were any remote indices that a search should have
been executed against. Previously, we used the list of remote shard iterators but if the remote
index pattern resolved to no indices there would be no remote shard iterators even though the
request specified remote indices. The map of remote cluster names to the original indices is used
instead so that we can determine if there were remote indices even when there are no remote shard
iterators.

Closes #25426
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment