opensearch-project / OpenSearch

🔎 Open source distributed and RESTful search engine.
https://opensearch.org/docs/latest/opensearch/index/
Apache License 2.0
9.84k stars 1.83k forks source link

[BUG] Field-level `ignore_malformed` should override index-level setting #16599

Open andrross opened 1 week ago

andrross commented 1 week ago

Describe the bug

The ignore_malformed property can be set at the index level and at the individual field level. I believe the field-level setting should override the index-level setting if both are present, but that is not the observed behavior for OpenSearch 2.4 and later.

Related component

Indexing

To Reproduce

Create an index like the following:

curl -X PUT -u admin:$PWD --insecure "https://localhost:9200/my-index-000001?pretty" -H 'Content-Type: application/json' -d'
{
  "settings": {
    "index.mapping.ignore_malformed": true
  },
  "mappings": {
    "properties": {
      "number_one": {
        "type": "byte"
      },
      "number_two": {
        "type": "integer",
        "ignore_malformed": false
      }
    }
  }
}
'

Index a document with a malformed value for the number_two field:

curl -X PUT -u admin:$PWD --insecure "https://localhost:9200/my-index-000001/_doc/2?pretty" -H 'Content-Type: application/json' -d'
{
  "text":       "Some text value",
  "number_two": "foo"
}
'

This succeeds, but it should fail because the ignore_malformed value has been set to false for that field.

Expected behavior

Field-level setting should override index-level setting.

Additional Details

This behaved as expected for versions of OpenSearch prior to 2.4.

Slack thread where originally reported: https://opensearch.slack.com/archives/C0539F41Z5X/p1730959987164549

RS146BIJAY commented 1 week ago

Thanks @andrross filing this bug. Looking forward for the fix of this issue.

Mishail commented 1 week ago

It may be related to #4494, which I believe makes the index-level ignore_malformed setting override field level