Skip to content

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

@tvernum

Description

@tvernum

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" }}]}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    :Search/SearchSearch-related issues that do not fall into other categories>bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions