Skip to content

Conversation

@bruce-hong-glean
Copy link
Contributor

@bruce-hong-glean bruce-hong-glean commented Aug 13, 2025

Description

This PR adds the dynamic: false_allow_templates option to the schema. This creates mappings for any field that matches properties or dynamic_templates, and ignores any fields that do not (as opposed to rejecting altogether).

Example from linked issue, the usage is:

  1. Create the index:
{
    "properties": {
        "url": { "type": "keyword" },
    },
    "dynamic": "false_allow_templates",
    "dynamic_templates": [
        {
            "dates": {
                "match": "date_*",
                "mapping": {
                    "type": "date",
                },
            },
        }
    ]
}
  1. url matches an explicit property and the fields date_timestamp and date_timezone math the dynamic template:
POST index1/_doc/1
{
  "url": "www.example.com",
  "date_timestamp": "...",
  "date_timezone": "...",
  "misc_field": "..."
}
  1. Produces the mapping:
{
    "properties": {
        "url": { "type": "keyword" },
        "date_timestamp": { "type": "date" },
        "date_timezone": { "type": "date" }
    }
}

This is a redo of the reverted PR here, with invalid tests removed.

Related Issues

Resolves #18617

Check List

  • Functionality includes testing.
  • API changes companion pull request created
  • Public documentation issue/PR created

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@github-actions github-actions bot added enhancement Enhancement or improvement to existing feature or request Indexing Indexing, Bulk Indexing and anything related to indexing labels Aug 13, 2025
@bruce-hong-glean bruce-hong-glean force-pushed the false-allow-dynamic-templates-2 branch from c23067a to a18dd07 Compare August 13, 2025 20:29
@bruce-hong-glean bruce-hong-glean changed the title add false_allow_templates as a dynamic mapping option Add false_allow_templates as a dynamic mapping option Aug 13, 2025
@github-actions
Copy link
Contributor

✅ Gradle check result for a18dd07: SUCCESS

@codecov
Copy link

codecov bot commented Aug 13, 2025

Codecov Report

❌ Patch coverage is 88.57143% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.94%. Comparing base (dc70bf6) to head (a18dd07).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...va/org/opensearch/index/mapper/DocumentParser.java 87.09% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #19065      +/-   ##
============================================
+ Coverage     72.87%   72.94%   +0.07%     
- Complexity    69380    69432      +52     
============================================
  Files          5647     5647              
  Lines        319084   319106      +22     
  Branches      46157    46163       +6     
============================================
+ Hits         232528   232778     +250     
+ Misses        67729    67466     -263     
- Partials      18827    18862      +35     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bruce-hong-glean
Copy link
Contributor Author

cc @gaobinlong not sure if you wanted to take another look. This is an exact copy of the previous with a few test cases removed.

@andrross andrross merged commit 292407b into opensearch-project:main Aug 13, 2025
56 checks passed
@andrross
Copy link
Member

Thanks for the quick fix @bruce-hong-glean!

RajatGupta02 pushed a commit to RajatGupta02/OpenSearch that referenced this pull request Aug 18, 2025
karenyrx pushed a commit to karenyrx/OpenSearch that referenced this pull request Aug 21, 2025
atris pushed a commit to atris/OpenSearch that referenced this pull request Aug 28, 2025
kh3ra pushed a commit to kh3ra/OpenSearch that referenced this pull request Sep 5, 2025
vinaykpud pushed a commit to vinaykpud/OpenSearch that referenced this pull request Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Enhancement or improvement to existing feature or request Indexing Indexing, Bulk Indexing and anything related to indexing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] dynamic mapping setting called "false_allow_templates"

2 participants