How to identify which fields are used/unused when using _default_ and dynamic mapping


#1

Elasticsearch 1.7.3 behavior.

Suppose I am using a default mapping and various types. My default mapping is a superset of my types fields, so, something like:

_default_: {
  properties: {
     "a": { "type": "string" },
     "b":{"type":"string"},
     ... etc
  }
}

If I understand correctly, when I create an index using this default mapping and a type A which uses field a, a new type gets dynamically created called A.

When I retrieve the mappings for this index and type, I become surprised when I see all the fields defined in default in the mappings for index/A.

I'm going to index a bunch of these, with several different types and about a hundred fields, with many tens of thousands of these event per second. I assume I want a fixed mapping for performance reasons.

Is there a way to find out which fields are actually in use (and/or are unused) so I can define a fixed mapping for type A? Is there any reason trying to do this violates certain philosophies of ES?

Thanks for any help.


(Ali Beyad) #2

All entries in the _default_ mapping are applied to every type in the index. If the _default_ mapping contains all the different fields that can occur in your documents, could your document model just have one type in which all the documents go in? Alternatively, I'm not sure of the nature of your data, but you could possibly take advantage of dynamic mapping: https://www.elastic.co/guide/en/elasticsearch/guide/current/custom-dynamic-mapping.html

There are no APIs to retrieve which fields are in use for a given index.


(system) #3