Skip to content

Rework FieldMapper and MappedFieldType #56814

@romseygeek

Description

@romseygeek

We currently have two abstractions that encapsulate different mapping types within elasticsearch. FieldMapper defines how a particular field from a json document should be indexed into lucene, while MappedFieldType defines factory methods for building queries against those fields. However, MappedFieldType also extends lucene's FieldType and so holds some index structure configuration, which really belongs on FieldMapper. As a result, it also handles some merging and consistency checking logic dealing with mapping updates, which again only really effect index-time structures.

We should rework the relationship here, decoupling MappedFieldType from FieldType and keeping it as a simple source of query factory methods. This would also make it easier to generate field types that point to other fields, adding functionality on the way. For example, if we reworked field aliases to be a simple pointer field type, then we could remove a lot of special-casing logic in MapperService that has to handle normal fields and aliases separately.

Because of the fairly complex coupling already involved here, this will need to be done in several steps:

  • Move mapping update consistency checks from MappedFieldType to FieldMapper (Move merge compatibility logic from MappedFieldType to FieldMapper #56915)
  • Stop MappedFieldType extending FieldType, and move index configuration to FieldMapper (MappedFieldType should not extend FieldType #57666)
  • Add a new abstraction on MappedFieldType encapsulating 'text search' config - analyzers, FieldType, etc (Exclude WindowsFS from SharedClusterSnapshotRestoreIT (#58020) #58023)
  • Remove base FieldMapper class references to lucene's FieldType
  • Remove 'global' FieldMapper fields that refer to specific data types
    • analyzers and similarity should move to TextSearchInfo
    • eager_global_ordinals only applies to keyword and join
    • index, doc_values and store won't apply to search-time only mappers, so maybe move them as well?
  • Make FieldMapper.fieldType() abstract, and don't require a MappedFieldType to be passed to the base class constructor. This will allow for late-binding of search fields, so that they can reference other field mappers.
  • Rename MappedFieldType to SearchField

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions