Global Search¶
Integration¶
Services integrate with Global Search through the GlobalSearchClientModule.
A service should implement this integration when it owns entities that need to be searchable from the shared Global Search feature.
The integration model is based on document maps:
- the source service chooses which entities participate in Global Search
- a document map defines how a source entity is transformed into a search document
- the document map also defines which event triggers reindexing for that entity
- the source service registers that map in its module configuration through the client module API
What the service must provide¶
To integrate an entity with Global Search, the service must provide:
-
The source entity
The domain or read-model entity that will be indexed. -
The triggering event
The event that indicates the searchable representation should be created or updated. -
A document map
A class that defines: - how to extract the indexed document identifier
- how to extract the event identifier used to locate the entity
- how to shape the indexed payload
-
which related data must be eagerly loaded before building the payload
-
Module registration
The module must register the document map throughGlobalSearchClientModuleOptions.
Responsibilities¶
The source service is responsible for:
- deciding which entities should be searchable
- choosing which events should trigger reindexing
- shaping a search-oriented payload
- including any related data needed to build the search document
Global Search is responsible for:
- receiving the indexing request
- upserting the document into the appropriate search index
- exposing search and autocomplete capabilities for consumers
Design guidance¶
The payload returned by the document map should be a search document, not a raw persistence model.
That means it should contain the fields that are useful for search scenarios, such as:
- identifiers
- names, codes, and descriptions
- lightweight related data needed for matching or display
Avoid sending data that is:
- large but not searchable
- sensitive and not intended for discovery
- shaped only for persistence concerns
Integration Example¶
The example below shows how a service can make WorkOrder searchable.
1. Source entity and event¶
In this case:
- WorkOrder is the entity that should appear in Global Search
- WorkOrderUpdated is the event that triggers reindexing
2. Document map¶
This map defines the integration contract for WorkOrder:
- GetPayload shapes the document that will be indexed
- GetId returns the document identifier used in Global Search
- GetEventIdField extracts the entity identifier from the triggering event
- UseIncludes ensures related data is loaded before the payload is built
3. Module registration¶
How to read this example¶
Using the previous example, the indexing flow is:
- A
WorkOrderis updated in the owning service. - The service publishes
WorkOrderUpdated. - The Global Search client integration handles that event.
- The configured
WorkOrderDocumentMapis used to: - locate the affected
WorkOrder - load the required related data
- build the payload to index
- The resulting search document is sent to Global Search and upserted into the search index.
This keeps the integration declarative: the service only needs to register the map, and the client module uses that configuration to drive indexing.
Practical notes¶
Keep payloads search-oriented¶
In the WorkOrder example, including Lines may be acceptable if line data is intentionally searchable or needed in the result payload.
However, services should avoid treating the payload as a raw entity dump. A better payload is usually one that contains only the fields needed for:
- matching
- ranking
- rendering the search result
Include related data explicitly¶
If the search document depends on navigation properties or related entities, those dependencies should be declared through UseIncludes() so the map can build a complete and consistent payload.