Skip to content

Dynamic Model: integrate with the Search add-on #5701

Description

@knstvk

Description

Entities and attributes added at runtime through the Dynamic Model add-on are invisible to the Search add-on. Search builds its index definitions from Java interfaces written at build time, so a dynamic entity has no index at all, and a dynamic attribute of a static entity is indexed only if the application's Java definition happens to map it, for example with the * wildcard. Search also does not learn about changes: saving a dynamic entity publishes no entity change event, and saving a static entity where only dynamic values changed publishes none either.

The wildcard case is worse than "not indexed". A Java definition with includeProperties = "*" on a static entity also maps the entity's dynamic reference attributes. When the referenced entity is changed or removed, Search reloads the owners with a JPQL query that a dynamic reference cannot answer. The failed query marks the save transaction rollback-only, so the save of the referenced entity fails. This affects both static and dynamic referenced entities.

Use case

An administrator extends the model at runtime, for example adds a taxId attribute to Customer or a new Contract entity, and wants these values found through full-text search without a redeploy. What is searchable should be decided in the same place where the attribute is declared, by the same person.

Expected behavior

  • A dynamic attribute can be marked searchable in the YAML model and in the Admin UI. String, enumeration and single-valued reference attributes are supported; collection and calculated attributes are rejected. A reference is indexed by the target's instance name, as for a static reference.
  • An entity, static or dynamic, is indexed when at least one of its dynamic attributes is searchable or when the application declares a Java index definition for it. Searchable attributes are added to an existing Java definition of the same entity; fields the Java definition already maps are kept.
  • Applying a model refreshes the index definitions and synchronizes the index schemas under the configured schema management strategy. Existing rows are not reindexed automatically; the existing reindex operation covers them.
  • Creating, updating or deleting a dynamic entity, and changing indexed dynamic values of a static entity, enqueues the entity for indexing.
  • Changing or removing an entity referenced through a dynamic reference reindexes the owners and never fails the save, whether the reference is marked searchable or mapped by a wildcard Java definition.
  • fullTextFilter works on a dynamic entity's list view. A search hit whose entity has no detail view shows a warning instead of failing.
  • The Searchable checkbox is shown in the Admin UI only when the Search add-on is present. An attribute that the application's own definition already indexes is shown as searchable and read-only, since the flag makes no difference for it.
  • Search gets a general way for a module to contribute index definitions derived from runtime metadata. Search stays independent of Dynamic Model; the dependency points the other way.
  • An application without the Search add-on is unaffected.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions