Skip to main content

Jupiter.Market.Elastic.Titles.Services.ElasticIndexService

This service uses the NEST client library to interact with Elasticsearch Cloud. It handles index lifecycle management, bulk operations, and maintains synchronization between PostgreSQL and the !:xref:Elastic.TitlesIndex.

Efficient upserts are performed using a hash-based change detection strategy: a deterministic hash is computed for each document and stored in Elasticsearch. Only documents with missing or changed hashes are re-indexed, avoiding unnecessary updates and per-document GETs.

See also: Architecture Overview

Methods

Jupiter.Market.Elastic.Titles.Services.ElasticIndexService.InitAsync

No summary available.

This method configures the NEST client with:Cloud connection pool using CloudId and API key authenticationDefault index name from settingsDebug mode for detailed loggingCustom field name inference (camelCase)Default mapping for DealTopicName type

See also: Configuration Guide

UpsertIndex

Upserts (inserts or updates) a single title document in the !:xref:Elastic.TitlesIndex using hash-based change detection. Also sends a Deal update message to the Service Bus with a randomized priority ("High" or "Medium") after a successful upsert.

This method computes a deterministic hash for the document and delegates to M:Jupiter.Market.Elastic.Titles.Services.ElasticIndexService.BulkUpsertTitlesAsync(System.Collections.Generic.List{Jupiter.Market.Elastic.Titles.Models.Title}). It avoids per-document GETs and deep JSON comparisons by using a hash field (DocHash) stored in Elasticsearch. If the hash matches the existing document, no re-indexing is performed.

After a successful upsert, a message is sent to the Deal Service Bus topic to notify the Deal service of the update. The message includes the Deal ID and a randomized priority ("High" or "Medium").

See also: Data Model

Parameters:

  • title: The object to index.

Returns: A if the document was indexed, or null if no changes were detected.

BulkUpsertTitlesAsync

No summary available.

This method computes a deterministic hash (DocHash) for each document using a canonical JSON representation. It then fetches existing hashes from Elasticsearch in a single ids query (source filtering only for ID and DocHash). Only documents whose hash is missing or different are included in the bulk index operation. This avoids unnecessary re-indexing and eliminates per-document GETs or deep JSON comparisons.

The hash is stored in the DocHash field of each document in Elasticsearch.

Parameters:

  • titles: List of documents to upsert.

Returns: A from Elasticsearch, or null if no documents required indexing.

DeleteFromIndex

Deletes a title document from the !:xref:Elastic.TitlesIndex.

This method silently handles exceptions to prevent failures when deleting non-existent documents. Used to clean up stale documents when titles are removed from !:xref:Table.Title.

Parameters:

  • titleId: The unique identifier of the title to delete.

QueryAndSendToServiceBusAsync

No summary available.

This method:Parses the QueryJson from ElasticsearchSettings configurationExecutes a scroll query against the Elasticsearch indexStreams document IDs in batches to Service Bus via ServiceBusMessageServiceLogs progress periodically

The query can potentially match millions of documents and uses Elasticsearch scroll API for efficient streaming without loading all results into memory.

Parameters:

  • cancellationToken: Cancellation token for the operation.
Build StatusBuild #20260326.1 | Commit: b0552d8 | Branch: HEAD | Built: 3/26/2026, 2:01:36 AM