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

Dotted named field values can merge with non-dotted fields of the same name #65333

Closed
n0othing opened this issue Nov 20, 2020 · 3 comments · Fixed by #85081
Closed

Dotted named field values can merge with non-dotted fields of the same name #65333

n0othing opened this issue Nov 20, 2020 · 3 comments · Fixed by #85081
Labels
>bug :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch

Comments

@n0othing
Copy link
Member

Elasticsearch version (bin/elasticsearch --version): version: 7.10.0, Build: default/tar/51e9d6f22758d0374a0f3f5c6e8f3a7997850f96/2020-11-09T21:30:33.964949Z, JVM: 15.0.1

Plugins installed: []

JVM version (java -version): JVM: 15.0.1 (bundled)

OS version (uname -a if on a Unix-like system): macOS 10.15.7

Description of the problem including expected versus actual behavior:

When using dynamic: false a field with a dot in its name, whose suffix matches a mapped field’s name has its values merged with the mapped field unexpectedly:

Steps to reproduce:

DELETE myindex

PUT myindex
{
  "mappings": {
    "dynamic": false,
    "properties": {
      "myfield": {
        "type": "keyword"
      }
    }
  }
}

PUT myindex/_doc/1?refresh=true
{
  "myfield": "foo",
  "something.myfield": [
    "bar",
    "baz"
  ]
}


GET myindex/_search?size=0
{
  "aggs": {
    "my_term_agg": {
      "terms": {
        "field": "myfield",
        "size": 10
      }
    }
  }
}

Results in:

# GET myindex/_search?size=0
{
  "took" : 22,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : [ ]
  },
  "aggregations" : {
    "my_term_agg" : {
      "doc_count_error_upper_bound" : 0,
      "sum_other_doc_count" : 0,
      "buckets" : [
        {
          "key" : "bar",
          "doc_count" : 1
        },
        {
          "key" : "baz",
          "doc_count" : 1
        },
        {
          "key" : "foo",
          "doc_count" : 1
        }
      ]
    }
  }
}

In the above, something.myfield's values are getting added to myfield. This doesn't happen if something.myfield is mapped/indexed.

@n0othing n0othing added >bug :Search Foundations/Mapping Index mappings, including merging and defining field types needs:triage Requires assignment of a team area label labels Nov 20, 2020
@elasticmachine elasticmachine added the Team:Search Meta label for search team label Nov 20, 2020
@elasticmachine
Copy link
Collaborator

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

@jtibshirani
Copy link
Contributor

Thanks @n0othing for raising this, it's a great catch. In addition to the requirements you listed, it seems this only happens if the dynamic field value is an array.

I think this bug has existed for a long time, I tested on 6.8 and saw the same issue. Here's the piece of code that seems to be off: DocumentParser.java#L573.

@jtibshirani jtibshirani removed the needs:triage Requires assignment of a team area label label Nov 20, 2020
javanna added a commit to javanna/elasticsearch that referenced this issue Mar 17, 2022
Previously, when using dynamic: false, an array field with a dot in its name, whose suffix matched
a mapped field’s name, had its values merged with the mapped field unexpectedly. This has been fixed by elastic#79922

This commit adds a test for that scenario and verifies that the bug is fixed.

Closes elastic#65333
@javanna
Copy link
Member

javanna commented Mar 17, 2022

This looks to have been fixed by #79922 . Opened #85081 to add a test around it.

javanna added a commit that referenced this issue Mar 18, 2022
Previously, when using dynamic: false, an array field with a dot in its name, whose suffix matched
a mapped field’s name, had its values merged with the mapped field unexpectedly. This has been fixed by #79922

This commit adds a test for that scenario and verifies that the bug is fixed.

Closes #65333
@javanna javanna added Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch and removed Team:Search Meta label for search team labels Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants