diff --git a/Directory.Packages.props b/Directory.Packages.props
index bdc497737..c4c27ef22 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -46,7 +46,7 @@
-
+
diff --git a/src/services/Elastic.Documentation.Search/Common/SearchQueryBuilder.cs b/src/services/Elastic.Documentation.Search/Common/SearchQueryBuilder.cs
index ef3e81764..9aa11d558 100644
--- a/src/services/Elastic.Documentation.Search/Common/SearchQueryBuilder.cs
+++ b/src/services/Elastic.Documentation.Search/Common/SearchQueryBuilder.cs
@@ -37,10 +37,16 @@ public static class SearchQueryBuilder
/// Shared document filter that excludes hidden documents and root URLs.
///
public static Query DocumentFilter { get; } =
- !(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 };
+ new BoolQuery
+ {
+ MustNot =
+ [
+ new TermsQuery(
+ Infer.Field(f => f.Url.Suffix("keyword")),
+ new TermsQueryField(["/docs", "/docs/", "/docs/404", "/docs/404/"])),
+ new TermQuery { Field = Infer.Field(f => f.Hidden), Value = true }
+ ]
+ };
///
/// Builds a diminish terms query to reduce scoring for common/noisy terms.
diff --git a/src/services/Elastic.Documentation.Search/FullSearchGateway.cs b/src/services/Elastic.Documentation.Search/FullSearchGateway.cs
index 00cdc092a..54838c253 100644
--- a/src/services/Elastic.Documentation.Search/FullSearchGateway.cs
+++ b/src/services/Elastic.Documentation.Search/FullSearchGateway.cs
@@ -140,7 +140,7 @@ private async Task SearchWithHybridRrf(FullSearchRequest reque
if (!response.IsValidResponse)
{
logger.LogWarning("Elasticsearch response is not valid. Reason: {Reason}",
- response.ElasticsearchServerError?.Error.Reason ?? "Unknown");
+ response.ElasticsearchServerError?.Error?.Reason ?? "Unknown");
}
return ProcessSearchResponse(response, request.Query, isSemanticQuery: true, request.IncludeHighlighting);
@@ -208,7 +208,7 @@ private async Task SearchLexicalOnly(FullSearchRequest request
if (!response.IsValidResponse)
{
logger.LogWarning("Elasticsearch response is not valid. Reason: {Reason}",
- response.ElasticsearchServerError?.Error.Reason ?? "Unknown");
+ response.ElasticsearchServerError?.Error?.Reason ?? "Unknown");
}
return ProcessSearchResponse(response, request.Query, isSemanticQuery: false, request.IncludeHighlighting);
diff --git a/src/services/Elastic.Documentation.Search/NavigationSearchGateway.cs b/src/services/Elastic.Documentation.Search/NavigationSearchGateway.cs
index dcb20c3e5..ec01a1494 100644
--- a/src/services/Elastic.Documentation.Search/NavigationSearchGateway.cs
+++ b/src/services/Elastic.Documentation.Search/NavigationSearchGateway.cs
@@ -96,7 +96,7 @@ public async Task SearchImplementation(string query, int
if (!response.IsValidResponse)
{
logger.LogWarning("Elasticsearch response is not valid. Reason: {Reason}",
- response.ElasticsearchServerError?.Error.Reason ?? "Unknown");
+ response.ElasticsearchServerError?.Error?.Reason ?? "Unknown");
}
return ProcessSearchResponse(response, searchQuery);
diff --git a/tests-integration/Search.IntegrationTests/SearchRelevanceTests.cs b/tests-integration/Search.IntegrationTests/SearchRelevanceTests.cs
index cc7ec6c35..2dd1bed05 100644
--- a/tests-integration/Search.IntegrationTests/SearchRelevanceTests.cs
+++ b/tests-integration/Search.IntegrationTests/SearchRelevanceTests.cs
@@ -101,7 +101,7 @@ public async Task SearchReturnsExpectedFirstResultWithExplain(string query, stri
if (results.Count == 0)
{
var countResponse = await clientAccessor.Client.CountAsync(c => c.Indices(clientAccessor.SearchIndex), TestContext.Current.CancellationToken);
- output.WriteLine($"Index document count: {(countResponse.IsValidResponse ? countResponse.Count.ToString(CultureInfo.InvariantCulture) : $"ERROR: {countResponse.ElasticsearchServerError?.Error.Reason}")}");
+ output.WriteLine($"Index document count: {(countResponse.IsValidResponse ? countResponse.Count.ToString(CultureInfo.InvariantCulture) : $"ERROR: {countResponse.ElasticsearchServerError?.Error?.Reason}")}");
}
results.Should().NotBeEmpty($"Search for '{query}' should return results (index: {clientAccessor.SearchIndex})");