Skip to content
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
4 changes: 4 additions & 0 deletions src/Elastic.Documentation/Search/DocumentationDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ protected static string CreateMapping(string? inferenceId) =>
"prefix": { "type": "text", "analyzer" : "hierarchy_analyzer" }
}
},
"hidden" : {
"type" : "boolean"
},
"applies_to" : {
"type" : "nested",
"properties" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,8 @@ public async ValueTask<bool> ExportAsync(MarkdownExportFileContext fileContext,
Title = i.NavigationTitle,
Url = i.Url
}).Reverse().ToArray(),
Headings = headings
Headings = headings,
Hidden = fileContext.NavigationItem.Hidden
};

AssignDocumentMetadata(doc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -100,7 +103,8 @@ private static Query BuildLexicalQuery(string searchQuery) =>
|| new MatchQuery(Infer.Field<DocumentDto>(f => f.Parents.First().Title), searchQuery) { Boost = 2.0f }
|| new MatchQuery(Infer.Field<DocumentDto>(f => f.Title), searchQuery) { Fuzziness = 1, Boost = 1.0f }
)
&& !(Query)new TermsQuery(Infer.Field<DocumentDto>(f => f.Url.Suffix("keyword")), new TermsQueryField(["/docs", "/docs/", "/docs/404", "/docs/404/"]));
&& !(Query)new TermsQuery(Infer.Field<DocumentDto>(f => f.Url.Suffix("keyword")), new TermsQueryField(["/docs", "/docs/", "/docs/404", "/docs/404/"]))
&& !(Query)new TermQuery { Field = Infer.Field<DocumentDto>(f => f.Hidden), Value = true };

/// <summary>
/// Builds the semantic search query for the given search term.
Expand All @@ -110,7 +114,8 @@ private static Query BuildSemanticQuery(string searchQuery) =>
|| new SemanticQuery("abstract.semantic_text", searchQuery) { Boost = 3.0f }
)
&& !(Query)new TermsQuery(Infer.Field<DocumentDto>(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<DocumentDto>(f => f.Hidden), Value = true };

/// <summary>
/// Normalizes the search query by replacing "dotnet" with "net".
Expand Down
Loading