Skip to content

Commit

Permalink
FIxed Housing Finance Transaction Search (#92)
Browse files Browse the repository at this point in the history
* FIxed Housing Finance Transaction Search

* Add more logging for errors

Co-authored-by: Sandip <Sandip@DESKTOP-8GSTDPG>
Co-authored-by: golosowa.anna <[email protected]>
  • Loading branch information
3 people authored Dec 1, 2021
1 parent 418c0d0 commit 962514c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion HousingSearchApi.Tests/HousingSearchApi.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<PackageReference Include="Docker.DotNet" Version="3.125.4" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Hackney.Core.ElasticSearch" Version="1.45.0" />
<PackageReference Include="Hackney.Shared.HousingSearch" Version="0.17.0" />
<PackageReference Include="Hackney.Shared.HousingSearch" Version="0.18.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.3" />
Expand Down
2 changes: 1 addition & 1 deletion HousingSearchApi/HousingSearchApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<PackageReference Include="Hackney.Core.Logging" Version="1.30.0" />
<PackageReference Include="Hackney.Core.Middleware" Version="1.30.0" />
<PackageReference Include="Hackney.Core.Validation" Version="1.30.0" />
<PackageReference Include="Hackney.Shared.HousingSearch" Version="0.17.0" />
<PackageReference Include="Hackney.Shared.HousingSearch" Version="0.18.0" />
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="4.1.1" />
Expand Down
9 changes: 5 additions & 4 deletions HousingSearchApi/V1/Gateways/SearchGateway.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,11 @@ public async Task<GetTransactionListResponse> GetListOfTransactions(GetTransacti

var searchResponse = await _elasticSearchWrapper.Search<QueryableTransaction, GetTransactionListRequest>(searchRequest).ConfigureAwait(false);

if (!searchResponse.IsValid)
{
throw new Exception($"Cannot load transactions list. Error: {searchResponse.ServerError}");
}
if (searchResponse == null) throw new Exception("Cannot get response from ElasticSearch instance");

if (!searchResponse.IsValid) throw new Exception($"Cannot load transactions list. Error: {searchResponse.ServerError}");

if (searchResponse.Documents == null) throw new Exception($"ElasticSearch instance returns no documents. Error: {searchResponse.ServerError}");

var transactions = searchResponse.Documents.Select(queryableTransaction => queryableTransaction.ToTransaction());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Elasticsearch.Net;
using HousingSearchApi.V1.Interfaces;
using HousingSearchApi.V1.Interfaces.Factories;

Expand Down Expand Up @@ -55,6 +56,11 @@ public async Task<ISearchResponse<T>> Search<T, TRequest>(TRequest request) wher

return result;
}
catch (ElasticsearchClientException e)
{
_logger.LogError(e, "ElasticSearch Search threw an ElasticSearchClientException. DebugInfo: " + e.DebugInformation);
throw;
}
catch (Exception e)
{
_logger.LogError(e, "ElasticSearch Search threw an exception");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,15 @@ public QueryContainer Create<TRequest>(TRequest request, QueryContainerDescripto
"sender.fullName",
"transactionType",
"paymentReference",
"bankAccountNumber",
"transactionDate",
"transactionAmount"
"bankAccountNumber"
})
.WithExactQuery(transactionSearchRequest.SearchText,
new List<string>
{
"sender.fullName",
"transactionType",
"paymentReference",
"bankAccountNumber",
"transactionDate",
"transactionAmount"
"bankAccountNumber"
})
.Build(q);
}
Expand Down

0 comments on commit 962514c

Please sign in to comment.