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
14 changes: 13 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,15 @@ csharp_style_expression_bodied_accessors = true:suggestion
csharp_style_expression_bodied_local_functions = when_on_single_line:error
dotnet_style_prefer_conditional_expression_over_return = false

csharp_alignment_tab_fill_style=optimal_fill
csharp_align_multiline_parameter=false
csharp_align_multiline_extends_list=false
csharp_align_multiline_array_and_object_initializer=false
csharp_align_multiline_switch_expression=false
csharp_align_multiline_property_pattern=false
csharp_align_multiline_list_pattern=false
indent_braces_inside_statement_conditions=false


# Suggest more modern language features when available
csharp_style_pattern_matching_over_is_with_cast_check = true:error
Expand All @@ -172,7 +181,7 @@ csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_object_initializers = false

# just a suggestion do to our JSON tests that use anonymous types to
# represent json quite a bit (makes copy paste easier).
Expand All @@ -190,6 +199,9 @@ csharp_space_between_method_call_parameter_list_parentheses = false
#Wrap
csharp_preserve_single_line_statements = false
csharp_preserve_single_line_blocks = true
csharp_place_simple_initializer_on_single_line = true
csharp_max_initializer_elements_on_line = 5
csharp_wrap_object_and_collection_initializer_style = wrap_if_long
resharper_wrap_object_and_collection_initializer_style = chop_always

# Resharper
Expand Down
4 changes: 3 additions & 1 deletion config/synonyms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ synonyms:
- [ "ecs", "elastic common schema" ]
- [ "ml", "machine learning" ]
- [ "eis", "elastic inference service" ]
- [ "traffic filter", "network security" ]
- [ "traffic filter", "network security" ]
- [ "sso", "single sign-on" ]
- [ "querydsl", "query dsl", "query dsl"]
1 change: 1 addition & 0 deletions docs-builder.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<File Path="tests-integration/Directory.Build.props" />
<Project Path="tests-integration/Elastic.Assembler.IntegrationTests/Elastic.Assembler.IntegrationTests.csproj" />
<Project Path="tests-integration/Elastic.Documentation.Api.IntegrationTests/Elastic.Documentation.Api.IntegrationTests.csproj" />
<Project Path="tests-integration/Search.IntegrationTests/Search.IntegrationTests.csproj" />
</Folder>
<Folder Name="/tests/">
<File Path="tests/Directory.Build.props" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App"/>

<PackageReference Include="Microsoft.Extensions.Http.Resilience"/>
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery"/>
Expand Down
7 changes: 7 additions & 0 deletions src/Elastic.Documentation/Search/DocumentationDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ public record DocumentationDocument
[JsonPropertyName("hash")]
public string Hash { get; set; } = string.Empty;

/// <summary>
/// Search title is a combination of the title and the url components.
/// This is used for querying to not reward documents with short titles contributing to heavily to scoring
/// </summary>
[JsonPropertyName("search_title")]
public string? SearchTitle { get; set; }

[JsonPropertyName("title")]
public string? Title { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ protected static string CreateMappingSetting(string synonymSetName) =>
"tokenizer": "group_tokenizer",
"filter": [
"lowercase",
"synonyms_filter"
"synonyms_filter",
"kstem"
]
},
"highlight_analyzer": {
Expand Down Expand Up @@ -231,13 +232,19 @@ protected static string CreateMapping(string? inferenceId) =>
}
},
"hash" : { "type" : "keyword" },
"search_title": {
"type": "text",
"search_analyzer": "synonyms_analyzer",
"fields": {
"completion": { "type": "search_as_you_type" }
}
},
"title": {
"type": "text",
"search_analyzer": "synonyms_analyzer",
"fields": {
"keyword": {
"type": "keyword"
}
"keyword": { "type": "keyword" },
"completion": { "type": "search_as_you_type", "search_analyzer": "synonyms_analyzer" }
{{(!string.IsNullOrWhiteSpace(inferenceId) ? $$""", "semantic_text": {{{InferenceMapping(inferenceId)}}}""" : "")}}
}
},
Expand All @@ -255,34 +262,24 @@ protected static string CreateMapping(string? inferenceId) =>
"headings": {
"type": "text",
"search_analyzer": "synonyms_analyzer"
},
"abstract": {
"type" : "text",
"search_analyzer": "synonyms_analyzer",
"fields" : {
{{(!string.IsNullOrWhiteSpace(inferenceId) ? $"\"semantic_text\": {{{InferenceMapping(inferenceId)}}}" : "")}}
}
}
{{(!string.IsNullOrWhiteSpace(inferenceId) ? AbstractInferenceMapping(inferenceId) : AbstractMapping())}}
}
}
""";

private static string AbstractMapping() =>
"""
, "abstract": {
"type": "text",
"search_analyzer": "synonyms_analyzer"
}
""";

private static string InferenceMapping(string inferenceId) =>
$"""
"type": "semantic_text",
"inference_id": "{inferenceId}"
""";

private static string AbstractInferenceMapping(string inferenceId) =>
// langugage=json
$$"""
, "abstract": {
{{InferenceMapping(inferenceId)}}
}
""";


public void Dispose()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,12 @@ private void AssignDocumentMetadata(DocumentationDocument doc)
doc.BatchIndexDate = _batchIndexDate;
}

private void CommonEnrichments(DocumentationDocument doc)
{
var urlComponents = doc.Url.Split('/');
doc.SearchTitle = $"{doc.Title} - ({string.Join(" ", urlComponents)}";
}

public async ValueTask<bool> ExportAsync(MarkdownExportFileContext fileContext, Cancel ctx)
{
var file = fileContext.SourceFile;
Expand Down Expand Up @@ -456,6 +462,7 @@ public async ValueTask<bool> ExportAsync(MarkdownExportFileContext fileContext,
};

AssignDocumentMetadata(doc);
CommonEnrichments(doc);

if (_indexStrategy == IngestStrategy.Multiplex)
return await _lexicalChannel.TryWrite(doc, ctx) && await _semanticChannel.TryWrite(doc, ctx);
Expand Down Expand Up @@ -490,6 +497,7 @@ public async ValueTask<bool> FinishExportAsync(IDirectoryInfo outputFolder, Canc
: string.Empty;
doc.Abstract = @abstract;
doc.Headings = headings;
CommonEnrichments(doc);

// Write to channels following the multiplex or reindex strategy
if (_indexStrategy == IngestStrategy.Multiplex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// 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 System.Diagnostics;
using Microsoft.Extensions.Logging;

namespace Elastic.Documentation.Api.Core.Search;
Expand Down
Loading
Loading