AircraftOps
Search
Posts

Typesense Indexing Worker

Architecture → Serverless Functions

This Lambda worker processes SQS indexing events and performs batched synchronization operations against the Typesense search cluster. It is responsible for document upserts, document deletions, synonym upserts, and synonym deletions, ensuring search indexes remain consistent with the platform datastore.


Primary Responsibilities
  • Consume SQS indexing events generated by upstream systems
  • Batch documents and synonyms by collection for efficient processing
  • Execute Typesense document upsert and delete operations
  • Execute Typesense synonym upsert and delete operations
  • Log batch-level summaries to simplify debugging and observability
Batch Processing Flow
  1. The Lambda receives a batch of SQS messages.
  2. Each message is parsed and grouped by:
    • Collection name
    • Operation type (upsert / delete / synonym actions)
  3. A batch summary is logged for visibility into indexing workload size.
  4. Batched operations are executed in strict order:
    • Document upserts
    • Document deletes
    • Synonym upserts
    • Synonym deletes
Document Upserts

Documents are grouped per collection and imported using the Typesense bulk import API with the upsert action. This ensures existing documents are updated while new documents are inserted without requiring separate existence checks.

Document Deletes

Deletions are executed using a filter-based bulk delete query targeting the document ID list. This enables multiple records to be removed in a single request, improving throughput and minimizing indexing latency.

Synonym Upserts

Synonym records are updated individually through the Typesense synonyms API, allowing search behavior adjustments without reindexing entire collections.

Synonym Deletes

Synonym removal operations are processed explicitly to ensure search behavior changes propagate immediately and consistently across query nodes.

Architectural Role

This worker forms the dedicated search-indexing execution layer of the platform. By decoupling indexing from core data mutation workflows using SQS, the system achieves independent scaling, controlled retry semantics, and consistent eventual synchronization between the primary datastore and the search engine.