Skip to content
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 aggregations don't include cluster alias in _index #25606

Closed
spalger opened this issue Jul 7, 2017 · 0 comments
Closed

Cross cluster aggregations don't include cluster alias in _index #25606

spalger opened this issue Jul 7, 2017 · 0 comments
Assignees
Labels
>bug :Search/Search Search-related issues that do not fall into other categories v6.0.0-beta1

Comments

@spalger
Copy link
Contributor

spalger commented Jul 7, 2017

Elasticsearch version: master
Plugins installed: none
JVM version: 1.8.0_121
OS version: macOS

Description of the problem including expected versus actual behavior:
When running a search on a remote cluster, remote documents include the cluster alias in the _index field so that the document can be properly addressed. This behavior does not apply to aggregations. When doing a terms agg on _index for instance, the terms do not include the cluster alias. The top_hits agg also doesn't enhance _index with the cluster alias.

Steps to reproduce:

  1. Start a node that remotes to itself

    ./bin/elasticsearch -E search.remote.local.seeds=localhost:9300
  2. Index a document

    curl -XPOST "http://localhost:9200/index/doc/id" -H 'Content-Type: application/json' -d'
    {
      "foo": "bar"
    }'
  3. Execute a search for the document via local and remote index names, which results in two unique documents (correct behavior) but one index term in the aggs and what appears to be two identical top_hits

    curl -XPOST "http://localhost:9200/index,local:index/_search" -H 'Content-Type: application/json' -d'
    {
      "aggs": {
        "indices": {
          "terms": {
            "field": "_index"
          },
          "aggs": {
            "hits": {
              "top_hits": {
                "size": 10
              }
            }
          }
        }
      }
    }'

    results:

    {
      "took": 7,
      "timed_out": false,
      "_shards": {
        "total": 10,
        "successful": 10,
        "failed": 0
      },
      "hits": {
        "total": 2,
        "max_score": 1,
        "hits": [
          {
            "_index": "index",
            "_type": "doc",
            "_id": "id",
            "_score": 1,
            "_source": {
              "foo": "bar"
            }
          },
          {
            "_index": "local:index",
            "_type": "doc",
            "_id": "id",
            "_score": 1,
            "_source": {
              "foo": "bar"
            }
          }
        ]
      },
      "aggregations": {
        "indices": {
          "doc_count_error_upper_bound": 0,
          "sum_other_doc_count": 0,
          "buckets": [
            {
              "key": "index",
              "doc_count": 2,
              "hits": {
                "hits": {
                  "total": 2,
                  "max_score": 1,
                  "hits": [
                    {
                      "_index": "index",
                      "_type": "doc",
                      "_id": "id",
                      "_score": 1,
                      "_source": {
                        "foo": "bar"
                      }
                    },
                    {
                      "_index": "index",
                      "_type": "doc",
                      "_id": "id",
                      "_score": 1,
                      "_source": {
                        "foo": "bar"
                      }
                    }
                  ]
                }
              }
            }
          ]
        }
      }
    }
@spalger spalger changed the title Cross Cluster aggregations don't include cluster in _index Cross cluster aggregations don't include cluster alias in _index Jul 7, 2017
@s1monw s1monw self-assigned this Jul 7, 2017
s1monw added a commit to s1monw/elasticsearch that referenced this issue Jul 10, 2017
We lost the cluster alias due to some special caseing in inner hits
and due to the fact that we didn't pass on the alias to the shard request.
This change ensures that we have the cluster alias present on the shard to
ensure all SearchShardTarget reads preserve the alias.

Relates to elastic#25606
@javanna javanna added the :Search/Search Search-related issues that do not fall into other categories label Jul 11, 2017
s1monw added a commit that referenced this issue Jul 11, 2017
We lost the cluster alias due to some special caseing in inner hits
and due to the fact that we didn't pass on the alias to the shard request.
This change ensures that we have the cluster alias present on the shard to
ensure all SearchShardTarget reads preserve the alias.

Relates to #25606
s1monw added a commit that referenced this issue Jul 11, 2017
We lost the cluster alias due to some special caseing in inner hits
and due to the fact that we didn't pass on the alias to the shard request.
This change ensures that we have the cluster alias present on the shard to
ensure all SearchShardTarget reads preserve the alias.

Relates to #25606
s1monw added a commit to s1monw/elasticsearch that referenced this issue Jul 25, 2017
Today when we aggregate on the `_index` field the cross cluster search
alias is not taken into account. Neither is it respected when we search
on the field. This change adds support for cluster alias when the cluster
alias is present on the `_index` field.

Closes elastic#25606
s1monw added a commit that referenced this issue Jul 26, 2017
Today when we aggregate on the `_index` field the cross cluster search
alias is not taken into account. Neither is it respected when we search
on the field. This change adds support for cluster alias when the cluster
alias is present on the `_index` field.

Closes #25606
s1monw added a commit that referenced this issue Jul 26, 2017
Today when we aggregate on the `_index` field the cross cluster search
alias is not taken into account. Neither is it respected when we search
on the field. This change adds support for cluster alias when the cluster
alias is present on the `_index` field.

Closes #25606
s1monw added a commit that referenced this issue Jul 26, 2017
Today when we aggregate on the `_index` field the cross cluster search
alias is not taken into account. Neither is it respected when we search
on the field. This change adds support for cluster alias when the cluster
alias is present on the `_index` field.

Closes #25606
@lcawl lcawl removed the v6.1.0 label Dec 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search/Search Search-related issues that do not fall into other categories v6.0.0-beta1
Projects
None yet
Development

No branches or pull requests

6 participants