Skip to content

Commit 36ad2a9

Browse files
committed
Add indexNamespace to synonyms
1 parent ed068e2 commit 36ad2a9

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Elastic.Markdown/Exporters/Elasticsearch/ElasticsearchExporter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ DistributedTransport transport
3333
{ "batch_index_date", d.BatchIndexDate.ToString("o") }
3434
}),
3535
GetMapping = () => CreateMapping(null),
36-
GetMappingSettings = () => CreateMappingSetting("docs"),
36+
GetMappingSettings = () => CreateMappingSetting($"docs-{indexNamespace}"),
3737
IndexFormat =
3838
$"{endpoint.IndexNamePrefix.Replace("semantic", "lexical").ToLowerInvariant()}-{indexNamespace.ToLowerInvariant()}-{{0:yyyy.MM.dd.HHmmss}}",
3939
ActiveSearchAlias = $"{endpoint.IndexNamePrefix.Replace("semantic", "lexical").ToLowerInvariant()}-{indexNamespace.ToLowerInvariant()}"

src/Elastic.Markdown/Exporters/Elasticsearch/ElasticsearchMarkdownExporter.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class ElasticsearchMarkdownExporter : IMarkdownExporter, IDisposable
3737
private readonly DateTimeOffset _batchIndexDate = DateTimeOffset.UtcNow;
3838
private readonly DistributedTransport _transport;
3939
private IngestStrategy _indexStrategy;
40+
private string _indexNamespace;
4041
private string _currentLexicalHash = string.Empty;
4142
private string _currentSemanticHash = string.Empty;
4243

@@ -54,7 +55,7 @@ SynonymsConfiguration synonyms
5455
_logger = logFactory.CreateLogger<ElasticsearchMarkdownExporter>();
5556
_endpoint = endpoints.Elasticsearch;
5657
_indexStrategy = IngestStrategy.Reindex;
57-
58+
_indexNamespace = indexNamespace;
5859
var es = endpoints.Elasticsearch;
5960

6061
var configuration = new ElasticsearchConfiguration(es.Uri)
@@ -92,7 +93,7 @@ public async ValueTask StartAsync(Cancel ctx = default)
9293
_currentLexicalHash = await _lexicalChannel.Channel.GetIndexTemplateHashAsync(ctx) ?? string.Empty;
9394
_currentSemanticHash = await _semanticChannel.Channel.GetIndexTemplateHashAsync(ctx) ?? string.Empty;
9495

95-
await PublishSynonymsAsync("docs", ctx);
96+
await PublishSynonymsAsync($"docs-{_indexNamespace}", ctx);
9697
_ = await _lexicalChannel.Channel.BootstrapElasticsearchAsync(BootstrapMethod.Failure, null, ctx);
9798

9899
// if the previous hash does not match the current hash, we know already we want to multiplex to a new index

0 commit comments

Comments
 (0)