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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect type for mappings.dynamic property #1796

Open
gsoldevila opened this issue Nov 28, 2022 · 4 comments
Open

Incorrect type for mappings.dynamic property #1796

gsoldevila opened this issue Nov 28, 2022 · 4 comments

Comments

@gsoldevila
Copy link

馃悰 Bug Report

The client.indices.get() API returns a String for the mappings.dynamic property, even when specifying a boolean.
This is error prone:

// dynamic === 'false'
if (response.mappings.dynamic) {
  console.log('ouch!');
}

To Reproduce

Create and retrieve a new index using the Dev Console:

PUT /test_index
{
  "mappings": {
    "dynamic": false
  }
}

GET /test_index

Notice how the dynamic property comes back as a String

{
  "test_index": {
    "aliases": {},
    "mappings": {
      "dynamic": "false"
    },
    "settings": {
      "index": {
        "routing": {
          "allocation": {
            "include": {
              "_tier_preference": "data_content"
            }
          }
        },
        "number_of_shards": "1",
        "provided_name": "test_index",
        "creation_date": "1669631337348",
        "number_of_replicas": "1",
        "uuid": "bUae4NZHTFu00mL0zH7pfw",
        "version": {
          "created": "8040099"
        }
      }
    }
  }
}

Expected behavior

We'd expect the dynamic property to have the correct type (in this case, a boolean).

Your Environment

  • node version: 16
  • @elastic/elasticsearch version: 8.6.0
  • os: Mac
@gsoldevila
Copy link
Author

Quick test reveals that the issue comes from ES side already:

> curl -X GET "kibana:changeme@localhost:9200/test_index?pretty" -H 'Content-Type: application/json'

So all in all, the safest / easiest solution might be to define the mappings.dynamic as a string instead.

Copy link
Contributor

This issue is stale because it has been open 90 days with no activity. Remove the stale label, or leave a comment, or this will be closed in 14 days.

@JoshMock
Copy link
Member

This one is labeled as an @es_quirk in the spec. The JS code generator should be handling it as a special case. I'll take a look soon.

Copy link
Contributor

This issue is stale because it has been open 90 days with no activity. Remove the stale label, or leave a comment, or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Feb 12, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 26, 2024
@JoshMock JoshMock reopened this Feb 27, 2024
@stale stale bot removed the stale label Feb 27, 2024
@JoshMock JoshMock self-assigned this Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants