Skip to content

Commit b23a0af

Browse files
authored
Use Elastic Inference Service (EIS) during indexing by default (#2203)
- Introduced `--no-eis` parameter to control EIS usage. - Updated `AssemblerIndexService` configuration and inference options. - Adjusted `ElasticsearchExporter` to handle `InferenceId` and `SearchInferenceId` based on `noEis`. - Enhanced mappings to support dynamic `inference_id`.
1 parent 1a7126e commit b23a0af

File tree

6 files changed

+24
-11
lines changed

6 files changed

+24
-11
lines changed

src/Elastic.Documentation.Configuration/DocumentationEndpoints.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class ElasticsearchEndpoint
2323
// inference options
2424
public int SearchNumThreads { get; set; } = 8;
2525
public int IndexNumThreads { get; set; } = 8;
26+
public bool NoElasticInferenceService { get; set; }
2627

2728
// index options
2829
public string IndexNamePrefix { get; set; } = "semantic-docs";
@@ -31,7 +32,6 @@ public class ElasticsearchEndpoint
3132
public int BufferSize { get; set; } = 100;
3233
public int MaxRetries { get; set; } = 3;
3334

34-
3535
// connection options
3636
public bool DebugMode { get; set; }
3737
public string? CertificateFingerprint { get; set; }

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ DistributedTransport transport
5656
ActiveSearchAlias = $"{endpoint.IndexNamePrefix}-{indexNamespace.ToLowerInvariant()}",
5757
IndexNumThreads = endpoint.IndexNumThreads,
5858
SearchNumThreads = endpoint.SearchNumThreads,
59-
InferenceCreateTimeout = TimeSpan.FromMinutes(endpoint.BootstrapTimeout ?? 4)
59+
InferenceCreateTimeout = TimeSpan.FromMinutes(endpoint.BootstrapTimeout ?? 4),
60+
UsePreexistingInferenceIds = !endpoint.NoElasticInferenceService,
61+
InferenceId = endpoint.NoElasticInferenceService ? null : ".elser-2-elastic",
62+
SearchInferenceId = endpoint.NoElasticInferenceService ? null : ".elser-2-elastic"
6063
});
6164

6265

@@ -250,15 +253,13 @@ protected static string CreateMapping(string? inferenceId) =>
250253

251254
private static string AbstractMapping() =>
252255
"""
253-
, "abstract": {
254-
"type": "text"
255-
}
256+
, "abstract": { "type": "text" }
256257
""";
257258

258-
private static string InferenceMapping(string _) =>
259+
private static string InferenceMapping(string inferenceId) =>
259260
$"""
260261
"type": "semantic_text",
261-
"inference_id": ".elser-2-elastic"
262+
"inference_id": "{inferenceId}"
262263
""";
263264

264265
private static string AbstractInferenceMapping(string inferenceId) =>

src/services/Elastic.Documentation.Assembler/Indexing/AssemblerIndexService.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ ICoreService githubActionsService
3636
/// <param name="noSemantic">Index without semantic fields</param>
3737
/// <param name="searchNumThreads">The number of search threads the inference endpoint should use. Defaults: 8</param>
3838
/// <param name="indexNumThreads">The number of index threads the inference endpoint should use. Defaults: 8</param>
39+
/// <param name="noEis">Do not use the Elastic Inference Service, bootstrap inference endpoint</param>
3940
/// <param name="bootstrapTimeout">Timeout in minutes for the inference endpoint creation. Defaults: 4</param>
4041
/// <param name="indexNamePrefix">The prefix for the computed index/alias names. Defaults: semantic-docs</param>
4142
/// <param name="forceReindex">Force reindex strategy to semantic index</param>
@@ -62,6 +63,7 @@ public async Task<bool> Index(IDiagnosticsCollector collector,
6263
bool? noSemantic = null,
6364
int? searchNumThreads = null,
6465
int? indexNumThreads = null,
66+
bool? noEis = null,
6567
int? bootstrapTimeout = null,
6668
// index options
6769
string? indexNamePrefix = null,
@@ -101,6 +103,8 @@ public async Task<bool> Index(IDiagnosticsCollector collector,
101103
cfg.SearchNumThreads = searchNumThreads.Value;
102104
if (indexNumThreads.HasValue)
103105
cfg.IndexNumThreads = indexNumThreads.Value;
106+
if (noEis.HasValue)
107+
cfg.NoElasticInferenceService = noEis.Value;
104108
if (!string.IsNullOrEmpty(indexNamePrefix))
105109
cfg.IndexNamePrefix = indexNamePrefix;
106110
if (bufferSize.HasValue)

src/services/Elastic.Documentation.Isolated/IsolatedIndexService.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ ICoreService githubActionsService
3333
/// <param name="noSemantic">Index without semantic fields</param>
3434
/// <param name="searchNumThreads">The number of search threads the inference endpoint should use. Defaults: 8</param>
3535
/// <param name="indexNumThreads">The number of index threads the inference endpoint should use. Defaults: 8</param>
36+
/// <param name="noEis">Do not use the Elastic Inference Service, bootstrap inference endpoint</param>
3637
/// <param name="bootstrapTimeout">Timeout in minutes for the inference endpoint creation. Defaults: 4</param>
3738
/// <param name="indexNamePrefix">The prefix for the computed index/alias names. Defaults: semantic-docs</param>
3839
/// <param name="forceReindex">Force reindex strategy to semantic index</param>
@@ -59,6 +60,7 @@ public async Task<bool> Index(IDiagnosticsCollector collector,
5960
bool? noSemantic = null,
6061
int? searchNumThreads = null,
6162
int? indexNumThreads = null,
63+
bool? noEis = null,
6264
int? bootstrapTimeout = null,
6365
// index options
6466
string? indexNamePrefix = null,
@@ -98,6 +100,8 @@ public async Task<bool> Index(IDiagnosticsCollector collector,
98100
cfg.SearchNumThreads = searchNumThreads.Value;
99101
if (indexNumThreads.HasValue)
100102
cfg.IndexNumThreads = indexNumThreads.Value;
103+
if (noEis.HasValue)
104+
cfg.NoElasticInferenceService = noEis.Value;
101105
if (!string.IsNullOrEmpty(indexNamePrefix))
102106
cfg.IndexNamePrefix = indexNamePrefix;
103107
if (bufferSize.HasValue)

src/tooling/docs-builder/Commands/Assembler/AssemblerIndexCommand.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ ICoreService githubActionsService
3333
/// <param name="noSemantic">Index without semantic fields</param>
3434
/// <param name="searchNumThreads">The number of search threads the inference endpoint should use. Defaults: 8</param>
3535
/// <param name="indexNumThreads">The number of index threads the inference endpoint should use. Defaults: 8</param>
36+
/// <param name="noEis">Do not use the Elastic Inference Service, bootstrap inference endpoint</param>
3637
/// <param name="indexNamePrefix">The prefix for the computed index/alias names. Defaults: semantic-docs</param>
3738
/// <param name="forceReindex">Force reindex strategy to semantic index</param>
3839
/// <param name="bootstrapTimeout">Timeout in minutes for the inference endpoint creation. Defaults: 4</param>
@@ -60,6 +61,7 @@ public async Task<int> Index(
6061
bool? noSemantic = null,
6162
int? searchNumThreads = null,
6263
int? indexNumThreads = null,
64+
bool? noEis = null,
6365
int? bootstrapTimeout = null,
6466

6567
// index options
@@ -93,7 +95,7 @@ public async Task<int> Index(
9395
// endpoint options
9496
endpoint, environment, apiKey, username, password,
9597
// inference options
96-
noSemantic, indexNumThreads, searchNumThreads, bootstrapTimeout,
98+
noSemantic, indexNumThreads, searchNumThreads, noEis, bootstrapTimeout,
9799
// channel and connection options
98100
indexNamePrefix, forceReindex, bufferSize, maxRetries, debugMode,
99101
// proxy options
@@ -106,7 +108,7 @@ static async (s, collector, state, ctx) => await s.Index(collector, state.fs,
106108
// endpoint options
107109
state.endpoint, state.environment, state.apiKey, state.username, state.password,
108110
// inference options
109-
state.noSemantic, state.searchNumThreads, state.indexNumThreads, state.bootstrapTimeout,
111+
state.noSemantic, state.searchNumThreads, state.indexNumThreads, state.noEis, state.bootstrapTimeout,
110112
// channel and connection options
111113
state.indexNamePrefix, state.forceReindex, state.bufferSize, state.maxRetries, state.debugMode,
112114
// proxy options

src/tooling/docs-builder/Commands/IndexCommand.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ ICoreService githubActionsService
3232
/// <param name="searchNumThreads">The number of search threads the inference endpoint should use. Defaults: 8</param>
3333
/// <param name="indexNumThreads">The number of index threads the inference endpoint should use. Defaults: 8</param>
3434
/// <param name="indexNamePrefix">The prefix for the computed index/alias names. Defaults: semantic-docs</param>
35+
/// <param name="noEis">Do not use the Elastic Inference Service, bootstrap inference endpoint</param>
3536
/// <param name="forceReindex">Force reindex strategy to semantic index</param>
3637
/// <param name="bootstrapTimeout">Timeout in minutes for the inference endpoint creation. Defaults: 4</param>
3738
/// <param name="bufferSize">The number of documents to send to ES as part of the bulk. Defaults: 100</param>
@@ -58,6 +59,7 @@ public async Task<int> Index(
5859
bool? noSemantic = null,
5960
int? searchNumThreads = null,
6061
int? indexNumThreads = null,
62+
bool? noEis = null,
6163
int? bootstrapTimeout = null,
6264

6365
// index options
@@ -91,7 +93,7 @@ public async Task<int> Index(
9193
// endpoint options
9294
endpoint, apiKey, username, password,
9395
// inference options
94-
noSemantic, indexNumThreads, searchNumThreads, bootstrapTimeout,
96+
noSemantic, indexNumThreads, noEis, searchNumThreads, bootstrapTimeout,
9597
// channel and connection options
9698
indexNamePrefix, forceReindex, bufferSize, maxRetries, debugMode,
9799
// proxy options
@@ -104,7 +106,7 @@ static async (s, collector, state, ctx) => await s.Index(collector, state.fs, st
104106
// endpoint options
105107
state.endpoint, state.apiKey, state.username, state.password,
106108
// inference options
107-
state.noSemantic, state.searchNumThreads, state.indexNumThreads, state.bootstrapTimeout,
109+
state.noSemantic, state.searchNumThreads, state.indexNumThreads, state.noEis, state.bootstrapTimeout,
108110
// channel and connection options
109111
state.indexNamePrefix, state.forceReindex, state.bufferSize, state.maxRetries, state.debugMode,
110112
// proxy options

0 commit comments

Comments
 (0)