MATIH Platform is in active MVP development. Documentation reflects current implementation status.
14. Context Graph & Ontology
Analytics & Ranking
Entity Suggestions

Entity Suggestions

The EntitySuggestionService provides auto-completion and typeahead suggestions for entity names, tags, properties, relationship types, and search queries. It uses a trie data structure for fast prefix lookups populated from graph data, combined with fuzzy matching and semantic suggestions.


Overview

Entity suggestions power the search-as-you-type experience in the data catalog and agent workbenches. The service returns ranked suggestions within milliseconds, combining prefix matching with context-aware relevance scoring.

Source: data-plane/ai-service/src/context_graph/services/entity_suggestion_service.py


Suggestion Types

TypeDescriptionExample
ENTITYEntity names and URNs"cust..." suggests "customer_events", "customer_features"
TAGEntity tags"pii..." suggests "pii-sensitive", "pii-masked"
PROPERTYEntity property names"sche..." suggests "schema_version", "schema_type"
RELATIONSHIPRelationship type names"DERI..." suggests "DERIVED_FROM"
QUERYPast search queries"show me..." suggests popular completions
RECENTRecently accessed entitiesEntities the user recently viewed
POPULARMost-accessed entitiesEntities with highest access counts

Suggestion Sources

SourceMethodLatency
PREFIX_MATCHTrie-based O(k) prefix lookupUnder 1ms
FUZZY_MATCHEdit distance matching2-5ms
HISTORYUser search historyUnder 1ms
POPULARITYAccess frequency rankingUnder 1ms
CONTEXTUALCurrent entity context5-10ms
SEMANTICEmbedding similarity50-100ms
GRAPH_STOREDirect graph query10-30ms

Configuration

from context_graph.services.entity_suggestion_service import SuggestionConfig
 
config = SuggestionConfig(
    max_suggestions=10,       # Maximum suggestions per request
    min_prefix_length=2,      # Minimum prefix length to trigger
    fuzzy_threshold=0.7,      # Minimum fuzzy match score
    history_weight=0.3,       # Weight for history-based suggestions
    popularity_weight=0.2,    # Weight for popularity-based suggestions
    recency_boost=0.1,        # Score boost for recently accessed entities
)

API Usage

REST Endpoint

GET /api/v1/context-graph/suggest?q=cust&tenant_id=acme&types=entity,tag&limit=10

Python API

service = get_entity_suggestion_service()
 
suggestions = await service.suggest(
    SuggestionRequest(
        prefix="cust",
        tenant_id="acme",
        suggestion_types=[SuggestionType.ENTITY, SuggestionType.TAG],
        max_results=10,
        context_entity_urn="urn:matih:dataset:acme:orders",
    ),
)

Ranking Algorithm

Suggestions are ranked by a composite score:

score = prefix_match_score * 0.4
      + popularity_score * 0.2
      + recency_score * 0.1
      + context_relevance * 0.2
      + fuzzy_bonus * 0.1

When a context_entity_urn is provided, entities that are graph-neighbors of the context entity receive a context relevance boost.


Trie Data Structure

The suggestion service maintains an in-memory trie populated from the graph store on startup and refreshed periodically. The trie provides O(k) prefix lookups where k is the prefix length, enabling sub-millisecond suggestion latency for prefix matches.