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

[BUG] dynamic_template throws class_cast_exception #12298

Open
sharathganga opened this issue Feb 13, 2024 · 2 comments
Open

[BUG] dynamic_template throws class_cast_exception #12298

sharathganga opened this issue Feb 13, 2024 · 2 comments
Labels
bug Something isn't working Indexing Indexing, Bulk Indexing and anything related to indexing

Comments

@sharathganga
Copy link

Describe the bug

I trying to use dynamic_templates to map nested objects in a document as flat_object but receive the following error which has something to do with dotted field names:

{
  "error": {
    "root_cause": [
      {
        "type": "class_cast_exception",
        "reason": "class_cast_exception: class org.opensearch.index.mapper.FlatObjectFieldMapper cannot be cast to class org.opensearch.index.mapper.ObjectMapper (org.opensearch.index.mapper.FlatObjectFieldMapper and org.opensearch.index.mapper.ObjectMapper are in unnamed module of loader 'app')"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "failed to parse",
    "caused_by": {
      "type": "class_cast_exception",
      "reason": "class_cast_exception: class org.opensearch.index.mapper.FlatObjectFieldMapper cannot be cast to class org.opensearch.index.mapper.ObjectMapper (org.opensearch.index.mapper.FlatObjectFieldMapper and org.opensearch.index.mapper.ObjectMapper are in unnamed module of loader 'app')"
    }
  },
  "status": 400
}

Related component

Indexing

To Reproduce

PUT _index_template/test_logs
{
  "index_patterns": [
    "test*"
  ],
  "template": {
    "mappings": {
      "dynamic_templates": [     
        {
          "nested_object_fields": {
            "match": "*",
            "match_mapping_type": "object",
            "mapping": {
              "type": "flat_object"
            }
          }
        }        
      ]   
    }
  }
}

PUT test_logs/_doc/1
{
  "k8s.application.name": "test-app",
  "k8s.container.restart_count": "0",  
  "k8s.namespace.name": "test",
  "k8s.pod.name": "test-app-9f45bf4b-v76fr",  
  "network": {
    "ip_address": "10.10.1.10", 
    "security_group_id": "sg-111111111111111", 
    "subnet_id": "subnet-111111111111111",
    "vpc_id": "vpc-111111111111111"
  }
}

Expected behavior

The dotted field names should be mapped as text and nested objects should be mapped as flat_object when indexed.

Additional Details

Plugins
None

Screenshots
If applicable, add screenshots to help explain your problem.

Host/Environment (please complete the following information):

  • OS: AWS Opensearch
  • Version 2.11

Additional context
Add any other context about the problem here.

@sharathganga sharathganga added bug Something isn't working untriaged labels Feb 13, 2024
@github-actions github-actions bot added the Indexing Indexing, Bulk Indexing and anything related to indexing label Feb 13, 2024
@peternied
Copy link
Member

[Triage - attendees 1 2 3 4 5 6 7 8]
@sharathganga Thanks for filing, we'd welcome a pull request to address this issue.

@sharathganga
Copy link
Author

@peternied I'm not familiar with Java. Would anyone be so kind as to provide a fix for this problem? Your assistance would be greatly appreciated.

Also is there a workaround for this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Indexing Indexing, Bulk Indexing and anything related to indexing
Projects
None yet
2 participants