Skip to content

Conversation

@Mpdreamz
Copy link
Member

@Mpdreamz Mpdreamz commented Oct 14, 2025

var options = new CatalogIndexChannelOptions<HashDocument>(Client.Transport)
{
	IndexFormat = indexPrefix + "{0:yyyy.MM.dd.HH-mm-ss-fffffff}",
	ActiveSearchAlias = indexPrefix + "search",
	BulkOperationIdLookup = c => c.Id,
	ScriptedHashBulkUpsertLookup = !useScriptedHashBulkUpsert ? null : (c, channelHash) =>
	{
		var hash = HashedBulkUpdate.CreateHash(channelHash, c.Id, c.Title ?? string.Empty);
		c.Hash = hash;
		return new HashedBulkUpdate("hash", hash, "ctx._source.index_batch_date = params.index_batch_date",
			new Dictionary<string, string>
			{
				{ "index_batch_date", c.IndexBatchDate.ToString("o") }

			});
	},

In this example instead of the default noop script when the hash matches you can now specify a different script to run.

Here we update index_batch_date always but only if the hash does not match will the whole document (with e.g an update_date) be updated.

This allows us to both query for updates (update_date gte start of indexing) and delete anything that wasn't part of this upate (index_batchdate lt start of indexing).

@Mpdreamz Mpdreamz self-assigned this Oct 14, 2025
@Mpdreamz Mpdreamz merged commit 28be59c into main Oct 14, 2025
9 checks passed
@Mpdreamz Mpdreamz deleted the feature/custom-script-updates branch October 14, 2025 16:42
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.

3 participants