diff --git a/src/Elastic.Documentation/Search/DocumentationDocument.cs b/src/Elastic.Documentation/Search/DocumentationDocument.cs index 78207d7a5..e4af64538 100644 --- a/src/Elastic.Documentation/Search/DocumentationDocument.cs +++ b/src/Elastic.Documentation/Search/DocumentationDocument.cs @@ -65,4 +65,8 @@ public record DocumentationDocument [JsonPropertyName("parents")] public ParentDocument[] Parents { get; set; } = []; + + [JsonPropertyName("hidden")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public bool Hidden { get; set; } } diff --git a/src/Elastic.Markdown/Exporters/Elasticsearch/ElasticsearchExporter.cs b/src/Elastic.Markdown/Exporters/Elasticsearch/ElasticsearchExporter.cs index 42a06ad81..6f94a3678 100644 --- a/src/Elastic.Markdown/Exporters/Elasticsearch/ElasticsearchExporter.cs +++ b/src/Elastic.Markdown/Exporters/Elasticsearch/ElasticsearchExporter.cs @@ -199,6 +199,9 @@ protected static string CreateMapping(string? inferenceId) => "prefix": { "type": "text", "analyzer" : "hierarchy_analyzer" } } }, + "hidden" : { + "type" : "boolean" + }, "applies_to" : { "type" : "nested", "properties" : { diff --git a/src/Elastic.Markdown/Exporters/Elasticsearch/ElasticsearchMarkdownExporter.cs b/src/Elastic.Markdown/Exporters/Elasticsearch/ElasticsearchMarkdownExporter.cs index b793fc89c..f64479b03 100644 --- a/src/Elastic.Markdown/Exporters/Elasticsearch/ElasticsearchMarkdownExporter.cs +++ b/src/Elastic.Markdown/Exporters/Elasticsearch/ElasticsearchMarkdownExporter.cs @@ -451,7 +451,8 @@ public async ValueTask ExportAsync(MarkdownExportFileContext fileContext, Title = i.NavigationTitle, Url = i.Url }).Reverse().ToArray(), - Headings = headings + Headings = headings, + Hidden = fileContext.NavigationItem.Hidden }; AssignDocumentMetadata(doc); diff --git a/src/api/Elastic.Documentation.Api.Infrastructure/Adapters/Search/ElasticsearchGateway.cs b/src/api/Elastic.Documentation.Api.Infrastructure/Adapters/Search/ElasticsearchGateway.cs index 6d943a884..9555e54be 100644 --- a/src/api/Elastic.Documentation.Api.Infrastructure/Adapters/Search/ElasticsearchGateway.cs +++ b/src/api/Elastic.Documentation.Api.Infrastructure/Adapters/Search/ElasticsearchGateway.cs @@ -48,6 +48,9 @@ internal sealed record DocumentDto [JsonPropertyName("applies_to")] public ApplicableTo? Applies { get; init; } + + [JsonPropertyName("hidden")] + public bool Hidden { get; init; } = false; } internal sealed record ParentDocumentDto @@ -100,7 +103,8 @@ private static Query BuildLexicalQuery(string searchQuery) => || new MatchQuery(Infer.Field(f => f.Parents.First().Title), searchQuery) { Boost = 2.0f } || new MatchQuery(Infer.Field(f => f.Title), searchQuery) { Fuzziness = 1, Boost = 1.0f } ) - && !(Query)new TermsQuery(Infer.Field(f => f.Url.Suffix("keyword")), new TermsQueryField(["/docs", "/docs/", "/docs/404", "/docs/404/"])); + && !(Query)new TermsQuery(Infer.Field(f => f.Url.Suffix("keyword")), new TermsQueryField(["/docs", "/docs/", "/docs/404", "/docs/404/"])) + && !(Query)new TermQuery { Field = Infer.Field(f => f.Hidden), Value = true }; /// /// Builds the semantic search query for the given search term. @@ -110,7 +114,8 @@ private static Query BuildSemanticQuery(string searchQuery) => || new SemanticQuery("abstract.semantic_text", searchQuery) { Boost = 3.0f } ) && !(Query)new TermsQuery(Infer.Field(f => f.Url.Suffix("keyword")), - new TermsQueryField(["/docs", "/docs/", "/docs/404", "/docs/404/"])); + new TermsQueryField(["/docs", "/docs/", "/docs/404", "/docs/404/"])) + && !(Query)new TermQuery { Field = Infer.Field(f => f.Hidden), Value = true }; /// /// Normalizes the search query by replacing "dotnet" with "net".