Skip to content

Ignore base class properties during auto mapping in ElasticSearch using NEST #2945

@nkdev89

Description

@nkdev89

I'm working on Elastic Search 5.4 and using NEST to create index in C#, When i do a automap for a class which in Inheriting from SortedDictionary, The base class properites like Count,Comparer,Items are added to the Mapping, Can some one please help me how to avoid this.

Thanks

 public class Document : SortedDictionary<string, dynamic>
 {
    public int Id { get; set; }
 }

The actual mapping I'm getting is

{"DocumentMapping": {
"mappings": {
  "Document": {
    "dynamic": "strict",
    "_all": {
      "enabled": false
    },
    "properties": null,
    "Documents": {
      "properties": {
        "Comparer": {
          "type": "object"
        },
        "Count": {
          "type": "integer"
        },
        "Item": {
          "type": "object",
          "include_in_all": false
        },
        "ID": {
          "type": "int "
        }
      }
    }
  }
}}}

What i need is

{"DocumentMapping": {
"mappings": {
  "Document": {
    "dynamic": "strict",
    "_all": {
      "enabled": false
    },
    "properties": null,
    "Documents": {
      "properties": 
        "ID": {
          "type": "int "
        }
      }
    }
  }
}}}

How do i ignore the the Comparer,Count and Item from my mapping JSON.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions