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

Field collapsing on alias field spanning 2+ indexes #50121

Closed
consulthys opened this issue Dec 12, 2019 · 3 comments
Closed

Field collapsing on alias field spanning 2+ indexes #50121

consulthys opened this issue Dec 12, 2019 · 3 comments
Assignees
Labels
>bug :Search/Search Search-related issues that do not fall into other categories

Comments

@consulthys
Copy link
Contributor

Elasticsearch version (bin/elasticsearch --version): ES Cloud 7.5

Plugins installed: []

JVM version (java -version): ES Cloud

OS version (uname -a if on a Unix-like system): ES Cloud

Disclaimer:

I'm creating this issue as requested by @spinscale in order to figure out if this is a bug or at least needs an update in the docs to properly mention why this doesn't work.

Description of the problem including expected versus actual behavior:

I'm trying to collapse on a field named field1 across different indexes. All indexes but one have the same field field1 and one index has a different field named field2. So, in that latter index, I'm defining an alias field field1 which points to field2. My hope is to be able to collapse on field1 across all indexes, but apparently this doesn't work.

Steps to reproduce:

Here is how to simply reproduce the problem I'm facing. First, we create two indexes:

PUT index1
{
  "settings": {
    "index.number_of_shards": 1
  }, 
  "mappings": {
    "properties": {
      "field1": {
        "type": "keyword"
      }
    }
  }
}

PUT index2
{
  "settings": {
    "index.number_of_shards": 1
  }, 
  "mappings": {
    "properties": {
      "field2": {
        "type": "keyword"
      },
      "field1": {
        "type": "alias",
        "path": "field2"
      }
    }
  }
}

Then we index one document in each index

PUT index1/_doc/1
{
  "field1": "test1"
}
PUT index2/_doc/1
{
  "field2": "test2"
}

And finally I'm trying to collapse on the "common" field

POST index*/_search 
{
  "collapse": {
    "field": "field1",
    "inner_hits": {
      "name": "hits"
    }
  }
}

And I get this:

{
  "error": {
    "root_cause": [],
    "type": "search_phase_execution_exception",
    "reason": "",
    "phase": "fetch",
    "grouped": true,
    "failed_shards": [],
    "caused_by": {
      "type": "illegal_argument_exception",
      "reason": "collapse field differ across shards [field1] != [field2]"
    }
  },
  "status": 400
}

I could not find anything in the documentation or in Github issues that would explain this. One would think that this is indeed possible, but I might be missing something obvious.

I'd appreciate if anyone could shed some light on this.
Thank you so much!

@pgomulka pgomulka added the :Search/Search Search-related issues that do not fall into other categories label Dec 12, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Search)

@jimczi jimczi added the >bug label Dec 12, 2019
@jtibshirani
Copy link
Contributor

Thanks @consulthys for reporting this, we've confirmed it's a bug in how field aliases interact with field collapsing.

@jtibshirani
Copy link
Contributor

This was fixed in #50722, and will be available in the upcoming 7.5.2 and 7.6.0 releases.

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
Projects
None yet
Development

No branches or pull requests

5 participants