Skip to content

An entity is fetched by its exact name with exact=true, so a lookup uses the name index instead of scanning the base - #1491

Merged
WaylandYang merged 2 commits into
deeplethe:devfrom
re-cinq:feat/entity-search-exact
Nov 10, 2026
Merged

WaylandYang merged 2 commits into
deeplethe:devfrom
re-cinq:feat/entity-search-exact

Conversation

@gedaiu

@gedaiu gedaiu commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1479

Entity search takes an optional exact=true. With it, the search matches only entities whose canonical name or a current alias equals the text (folded to lower case), so the lookup goes through the existing name indexes (entities_kb_name_idx for the canonical name, facts_value_text_idx for aliases) instead of scanning the whole base with ILIKE '%text%'. The two are read as one set of ids, because an OR with a subquery on one side leaves the planner a scan of the base's entities. In a replay (as_of) the canonical-name index cannot serve, since it only holds entities that are not merged today, so that half filters the base's entities instead. The total is counted the same way. Without the parameter nothing changes: it is the same substring search, the exact name still sorts first, and the MCP lookup tool passes false. On our base a lookup by file path took 11.5 to 17.6 s, against 0.8 s for the entity_detail that follows it. On a seeded base of 300k entities the default search takes about 1.4 s and exact=true about 70 ms.

There is a store test for a.ts against a.ts#parse (exact, default and mixed case) a replay case for an entity that was merged later, and a route test with a read token, which can already reach this route, so no auth or ADR change is needed.

This follows the proposal in the issue, and we are glad to reshape it however you prefer.

…ses the name index instead of scanning the base

Signed-off-by: Bogdan Szabo <bogdan@re-cinq.com>
…longer scans the base's entities

Signed-off-by: Bogdan Szabo <bogdan@re-cinq.com>

@WaylandYang WaylandYang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the exact path keeps the default unchanged and uses the index. Merging.

@WaylandYang
WaylandYang merged commit 1715d56 into deeplethe:dev Nov 10, 2026
6 checks passed
gedaiu added a commit to re-cinq/utopia that referenced this pull request Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants