Skip to content

Multi-tenant custom field support #98

@ejsmith

Description

@ejsmith

Patternize multi-tenant custom field handling

  • Custom field mapping storage
    • Entity type (repo), tenant (should allow for composite like organization+type), field type, friendly name, extensible to store additional mapping information
    • Shared across multiple entity types and tenants
    • Auto assign index slots to new custom fields
    • Fill in gaps for index slots when fields have been deleted
    • Ability to efficiently lookup field mapping for an entity type and tenant
      • Aggressively cache mapping for the tenant
    • Ability to have a list of aliases for a field that will be used to resolve queries
      • Only the root name will be used for getting data that gets added to the idx slot
      • Aliases count as used names can't be used by other fields
  • Extensible field types
    • Packaged up field type behaviors that can be re-used
    • Built in field types for string, date, bool, number, float, etc
    • Consumers can create custom field types to add additional indexing formats like address, geo, etc
    • Ability to transform values when adding them to idx
      • Allows the data to be optimized for searching
      • Allows things to happen like looking up related data to store denormalized
      • Probably needs to allow batching of values for efficiency when doing idx transforms
    • Standard field types automatically configured, but can be overridden with custom behavior
    • Ignore errors for invalid document field values when saving
    • Ability to do advanced things like scripted fields that have access to the rest of the document to calculate values (proven out in tests) https://github.com/FoundatioFx/Foundatio.Repositories/blob/master/tests/Foundatio.Repositories.Elasticsearch.Tests/Repositories/Configuration/Indexes/CalculatedIntegerFieldType.cs
  • Easily implemented in repositories
    • Interface for model to implement that opts the repository into supporting custom fields
    • Automatically copies values from friendly names to idx slots
    • Automatically gets mapping and sets QueryFieldResolver on queries
  • Field management
    • Ability to change type of an existing field
      • Could start out as an auto field indexed as string and then be changed to a date or some other more specific type
    • Ability to remove a field
      • Cleanup idx values
      • Optionally remove custom field values
    • Ability to rename a field
  • Ability to auto create custom fields on the fly when we see a new value that does not have a mapping
    • Default to store as string with keyword subfield
    • Hook when auto creating custom property mappings that lets you decide if a mapping should be created and determine the default index type

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions