Skip to content

Add Search/AI Assistant to dev enviroment. #1736

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/assembler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ environments:
uri: http://localhost:4000
content_source: current
path_prefix: docs
feature_flags:
SEARCH_OR_ASK_AI: true

shared_configuration:
stack: &stack
Expand Down
1 change: 0 additions & 1 deletion src/tooling/docs-builder/Http/DocumentationWebHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ private void SetUpRoutes()
_ = _webApplication.MapGet("/api/{**slug}", (string slug, ReloadableGeneratorState holder, Cancel ctx) =>
ServeApiFile(holder, slug, ctx));


var apiV1 = _webApplication.MapGroup("/docs/_api/v1");
apiV1.MapElasticDocsApiEndpoints();

Expand Down
8 changes: 7 additions & 1 deletion src/tooling/docs-builder/Http/StaticWebHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information

using Elastic.Documentation.Api.Infrastructure;
using Elastic.Documentation.Configuration;
using Elastic.Documentation.ServiceDefaults;
using Elastic.Documentation.Tooling;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
Expand All @@ -28,6 +28,8 @@ public StaticWebHost(int port)

_ = builder.AddDocumentationServiceDefaults();

builder.Services.AddElasticDocsApiUsecases("dev");

_ = builder.Logging
.AddFilter("Microsoft.AspNetCore.Hosting.Diagnostics", LogLevel.Error)
.AddFilter("Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware", LogLevel.Error)
Expand All @@ -51,6 +53,10 @@ private void SetUpRoutes()
_ = WebApplication.MapGet("/", (Cancel _) => Results.Redirect("docs"));

_ = WebApplication.MapGet("{**slug}", ServeDocumentationFile);

var apiV1 = WebApplication.MapGroup("/docs/_api/v1");
apiV1.MapElasticDocsApiEndpoints();

}

private async Task<IResult> ServeDocumentationFile(string slug, Cancel _)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public async ValueTask InitializeAsync()
_ = builder.Services.AddElasticDocumentationLogging(LogLevel.Information);
_ = builder.Services.AddLogging(c => c.AddXUnit());
_ = builder.Services.AddLogging(c => c.AddInMemory());
// TODO expose this as secrets for now not needed integration tests
_ = builder.AddParameter("LlmGatewayUrl", "");
_ = builder.AddParameter("LlmGatewayServiceAccountPath", "");
DistributedApplication = await builder.BuildAsync();
InMemoryLogger = DistributedApplication.Services.GetService<InMemoryLogger>()!;
await DistributedApplication.StartAsync();
Expand Down
34 changes: 30 additions & 4 deletions tests-integration/Elastic.Documentation.Aspire/AppHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,39 @@

var builder = DistributedApplication.CreateBuilder(args);

// Add a secret parameter named "secret"
var llmUrl = builder.AddParameter("LlmGatewayUrl", secret: true);
var llmServiceAccountPath = builder.AddParameter("LlmGatewayServiceAccountPath", secret: true);

var cloneAll = builder.AddProject<Projects.docs_assembler>("DocsAssemblerCloneAll").WithArgs(["repo", "clone-all", .. globalArguments]);

var buildAll = builder.AddProject<Projects.docs_assembler>("DocsAssemblerBuildAll").WithArgs(["repo", "build-all", .. globalArguments])
.WaitForCompletion(cloneAll);

var elasticsearch = builder.AddElasticsearch("elasticsearch");
var elasticsearch = builder.AddElasticsearch("elasticsearch")
.WithEnvironment("LICENSE", "trial");

var api = builder.AddProject<Projects.Elastic_Documentation_Api_Lambda>("ApiLambda").WithArgs(globalArguments)
.WithEnvironment("ENVIRONMENT", "dev")
.WithEnvironment("LLM_GATEWAY_FUNCTION_URL", llmUrl)
.WithEnvironment("LLM_GATEWAY_SERVICE_ACCOUNT_KEY_PATH", llmServiceAccountPath)
.WaitFor(elasticsearch)
.WithReference(elasticsearch);

var indexElasticsearch = builder.AddProject<Projects.docs_assembler>("DocsAssemblerElasticsearch")
.WithArgs(["repo", "build-all", "--exporters", "html,elasticsearch", .. globalArguments])
.WithArgs(["repo", "build-all", "--exporters", "elasticsearch", .. globalArguments])
.WithEnvironment("DOCUMENTATION_ELASTIC_URL", elasticsearch.GetEndpoint("http"))
.WithEnvironment(context =>
{
context.EnvironmentVariables["DOCUMENTATION_ELASTIC_PASSWORD"] = elasticsearch.Resource.PasswordParameter;
})
.WithReference(elasticsearch)
.WithExplicitStart()
.WaitFor(elasticsearch)
.WaitForCompletion(cloneAll);

var indexElasticsearchSemantic = builder.AddProject<Projects.docs_assembler>("DocsAssemblerElasticsearchSemantic")
.WithArgs(["repo", "build-all", "--exporters", "semantic", .. globalArguments])
.WithEnvironment("DOCUMENTATION_ELASTIC_URL", elasticsearch.GetEndpoint("http"))
.WithEnvironment(context =>
{
Expand All @@ -44,11 +64,17 @@

var serveStatic = builder.AddProject<Projects.docs_builder>("DocsBuilderServeStatic")
.WithReference(elasticsearch)
.WithEnvironment("LLM_GATEWAY_FUNCTION_URL", llmUrl)
.WithEnvironment("LLM_GATEWAY_SERVICE_ACCOUNT_KEY_PATH", llmServiceAccountPath)
.WithEnvironment("DOCUMENTATION_ELASTIC_URL", elasticsearch.GetEndpoint("http"))
.WithEnvironment(context =>
{
context.EnvironmentVariables["DOCUMENTATION_ELASTIC_PASSWORD"] = elasticsearch.Resource.PasswordParameter;
})
.WithHttpEndpoint(port: 4000, isProxied: false)
.WithArgs(["serve-static", .. globalArguments])
.WithHttpHealthCheck("/", 200)
.WaitFor(elasticsearch)
.WaitForCompletion(buildAll);



builder.Build().Run();
Loading