Skip to content

feat: use trigram index on objectid for improved search - BED-9103 - #3206

Draft
StranDutton wants to merge 2 commits into
mainfrom
feature/BED-9103-raw-object-id-search-index
Draft

feat: use trigram index on objectid for improved search - BED-9103#3206
StranDutton wants to merge 2 commits into
mainfrom
feature/BED-9103-raw-object-id-search-index

Conversation

@StranDutton

@StranDutton StranDutton commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Description

Updates raw ObjectID fuzzy and prefix search to use DAWGS' upcoming indexable case-insensitive predicates when the use_raw_object_id feature flag is enabled.

Adds an ObjectID text-search index to the graph schema so PostgreSQL can efficiently search both Name and ObjectID from the shared Search/Explore input.

Exact ObjectID matching remains case-sensitive. Flag-off search behavior is unchanged.

This PR depends on a related DAWGS PR

Caution

The Dawgs version must be updated after the related PR is merged.

Motivation and Context

Resolves BED-9103

The raw objectIDs feature flag preserves source casing. Fuzzy and prefix search must therefore be case-insensitive while still searching both Name and ObjectID.

The existing raw-ObjectID fuzzy and prefix query shape scans graph nodes because its PostgreSQL helpers use strpos and left rather than ILIKE, preventing PostgreSQL from using trigram indexes. ObjectID has an exact-match B-tree index but no text-search index for fuzzy or prefix matching.

This change enables an indexable query shape for the feature-flagged raw ObjectID search path and adds the missing ObjectID text-search index.

No Goose migration is needed. The ObjectID text-search index is declared in the Dawgs graph schema and is created when graph schema assertion runs.

Caution

Production rollout must ensure the updated graph schema is asserted so the index is created. Dawgs currently uses ordinary index creation, not CREATE INDEX CONCURRENTLY.

How Has This Been Tested?

Focused BHE query and graph-schema tests were run using a temporary workspace with the local Dawgs checkout.

Manual PostgreSQL EXPLAIN (ANALYZE, BUFFERS) benchmarks were run against a local GitHub graph containing 38,655 nodes:

  • Current raw-ObjectID fuzzy query shape: sequential scan, ~74 ms.
  • Proposed fuzzy query shape: Name/ObjectID BitmapOr trigram-index plan, ~5.7 ms.
  • Current raw-ObjectID prefix query shape: sequential scan, ~81 ms.
  • Proposed prefix query shape: Name/ObjectID BitmapOr trigram-index plan, ~6.5 ms.

The authenticated /api/v2/search endpoint was also exercised with use_raw_object_id enabled. Warm requests completed in approximately 6-7 ms.

Types of Changes

  • New feature (non-breaking change which adds functionality)

Checklist

I have met the contributing prerequisites

I have ensured that related documentation is up-to-date

  • OpenAPI docs: not applicable
  • Code comments (GoDocs / JSDocs)
  • I have followed proper test practices
  • Added/updated tests to cover my changes
  • Full test suite run

@StranDutton StranDutton self-assigned this Aug 25, 2026
@StranDutton StranDutton added the enhancement New feature or request label Aug 25, 2026
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Comment @coderabbitai help to get the list of available commands.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant