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
10 changes: 4 additions & 6 deletions src/Textkernel.Tx.SDK.Tests/IntegrationTests/MatchV2Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,18 @@ public async Task TestMatch()

Assert.ThrowsAsync<TxException>(async () =>
{
await Client.SearchMatchV2.MatchJobs("fake-doc-id", opts);
await Client.SearchMatchV2.MatchJobs(new DocumentSource { Id = "fake-doc-id" }, opts);
});

opts.DocumentType = DocumentType.vacancy;
Assert.DoesNotThrow(() =>
{
var response = Client.SearchMatchV2.MatchJobs(_documentId, opts).Result.Value;
var response = Client.SearchMatchV2.MatchJobs(new DocumentSource { Id = _documentId, Type = DocumentType.vacancy }, opts).Result.Value;
Assert.IsNotEmpty(response.ResultItems);
});

opts.DocumentType = DocumentType.vacancy;
Assert.DoesNotThrow(() =>
{
var response = Client.SearchMatchV2.MatchCandidates(_documentId, opts).Result.Value;
var response = Client.SearchMatchV2.MatchCandidates(new DocumentSource { Id = _documentId, Type = DocumentType.vacancy }, opts).Result.Value;
Assert.IsNotEmpty(response.ResultItems);
});

Expand All @@ -153,7 +151,7 @@ public async Task TestAutocomplete()

Assert.DoesNotThrow(() =>
{
var response = Client.SearchMatchV2.AutocompleteJobs(AutocompleteJobsField.JobTitle, "Softwa").Result;
var response = Client.SearchMatchV2.AutocompleteJobs(AutocompleteJobsField.Location, "York").Result;
Assert.IsNotEmpty(response.Value.Return);
});

Expand Down
2 changes: 1 addition & 1 deletion src/Textkernel.Tx.SDK.Tests/TestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Personal Information

private static string _jobOrderTextTech = @"
Position Title: Sr. Software Developer

Location: New York, US
Skills:
JavaScript
ReactJS";
Expand Down
4 changes: 2 additions & 2 deletions src/Textkernel.Tx.SDK/ApiEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ private static string Sanitize(string indexOrDocId)
internal static HttpRequestMessage MatchV2CandidatesAddDocument(string documentId) => new HttpRequestMessage(HttpMethod.Post, $"matchv2/candidates/{documentId}");
internal static HttpRequestMessage MatchV2CandidatesDeleteDocuments(IEnumerable<string> documentIds, string env) => new HttpRequestMessage(HttpMethod.Delete, $"matchv2/candidates?ids={string.Join(",", documentIds)}&SearchAndMatchEnvironment={env}");
internal static HttpRequestMessage MatchV2CandidatesSearch() => new HttpRequestMessage(HttpMethod.Post, $"matchv2/candidates/search");
internal static HttpRequestMessage MatchV2CandidatesMatchDocument(string documentId) => new HttpRequestMessage(HttpMethod.Post, $"matchv2/candidates/match/{documentId}");
internal static HttpRequestMessage MatchV2CandidatesMatchDocument() => new HttpRequestMessage(HttpMethod.Post, $"matchv2/candidates/match");
internal static HttpRequestMessage MatchV2CandidatesAutocomplete() => new HttpRequestMessage(HttpMethod.Post, $"matchv2/candidates/autocomplete");
internal static HttpRequestMessage MatchV2JobsAddDocument(string documentId) => new HttpRequestMessage(HttpMethod.Post, $"matchv2/vacancies/{documentId}");
internal static HttpRequestMessage MatchV2JobsDeleteDocuments(IEnumerable<string> documentIds, string env) => new HttpRequestMessage(HttpMethod.Delete, $"matchv2/vacancies?ids={string.Join(",", documentIds)}&SearchAndMatchEnvironment={env}");
internal static HttpRequestMessage MatchV2JobsSearch() => new HttpRequestMessage(HttpMethod.Post, $"matchv2/vacancies/search");
internal static HttpRequestMessage MatchV2JobsMatchDocument(string documentId) => new HttpRequestMessage(HttpMethod.Post, $"matchv2/vacancies/match/{documentId}");
internal static HttpRequestMessage MatchV2JobsMatchDocument() => new HttpRequestMessage(HttpMethod.Post, $"matchv2/vacancies/match");
internal static HttpRequestMessage MatchV2JobsAutocomplete() => new HttpRequestMessage(HttpMethod.Post, $"matchv2/vacancies/autocomplete");
}
}
23 changes: 23 additions & 0 deletions src/Textkernel.Tx.SDK/Models/API/MatchV2/Request/DocumentSource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright © 2023 Textkernel BV. All rights reserved.
// This file is provided for use by, or on behalf of, Textkernel licensees
// within the terms of their license of Textkernel products or Textkernel customers
// within the Terms of Service pertaining to the Textkernel SaaS products.

namespace Textkernel.Tx.Models.API.MatchV2.Request
{
/// <summary>
/// Defines a document that can be used to generate a match query.
/// </summary>
public class DocumentSource
{
/// <summary>
/// Specify what type of document is being passed to the match engine.
/// </summary>
public DocumentType Type { get; set; }

/// <summary>
/// Id of the document in the index to generate the query from.
/// </summary>
public string Id { get; set; }
}
}
12 changes: 11 additions & 1 deletion src/Textkernel.Tx.SDK/Models/API/MatchV2/Request/MatchRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,18 @@ public class MatchRequest
public MatchV2Environment SearchAndMatchEnvironment { get; set; }

/// <summary>
/// The options for the Search/Match request
/// The options for the Match request
/// </summary>
public Options Options { get; set; }

/// <summary>
/// The query object that will be combined with the match query to drive the search.
/// </summary>
public SearchQuery Query { get; set; }

/// <summary>
/// The document to generate the search query from.
/// </summary>
public DocumentSource SourceDocument { get; set; }
}
}
5 changes: 2 additions & 3 deletions src/Textkernel.Tx.SDK/Models/API/MatchV2/Request/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,8 @@ public class Options
public Sorting[] Sorting { get; set; }

/// <summary>
/// Allows for users to specify what type of document is being passed to the match process. Document ID must be
/// specifed and the match process needs to know if the documentId is of type candidate or job.
/// Optional flag indicating that the backend needs to use the Natural Language Query Service (NLQS) to interpret the query string.
/// </summary>
public DocumentType DocumentType { get; set; }
public bool UseNLQS { get; set; }
}
}
11 changes: 0 additions & 11 deletions src/Textkernel.Tx.SDK/Models/API/MatchV2/Request/SearchRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,6 @@

namespace Textkernel.Tx.Models.API.MatchV2.Request
{
/// <summary>
/// Request body for a Search request
/// </summary>
public class SearchRequest : MatchRequest
{
/// <summary>
/// The query object that will drive the search.
/// </summary>
public SearchQuery Query { get; set; }
}

/// <summary>
/// A search query
/// </summary>
Expand Down
10 changes: 6 additions & 4 deletions src/Textkernel.Tx.SDK/Services/IMatchV2Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ public interface IMatchV2Service
/// <summary>
/// Match an existing candidate document with filters provided.
/// </summary>
/// <param name="documentId">The document id that the user would like to run a match on.</param>
/// <param name="query">The query object that will be combined with the match query to drive the search</param>
/// <param name="options">Options for the Match request</param>
/// <param name="sourceDocument">The document to generate the search query from</param>
/// <exception cref="TxException">Thrown when an API error occurred</exception>
Task<SearchResponse> MatchCandidates(string documentId, Options options);
Task<SearchResponse> MatchCandidates(DocumentSource sourceDocument, Options options, SearchQuery query = null);

/// <summary>
/// Search for a candidate based on the query provided.
Expand Down Expand Up @@ -95,10 +96,11 @@ public interface IMatchV2Service
/// <summary>
/// Match an existing job document with filters provided.
/// </summary>
/// <param name="documentId">The document id that the user would like to run a match on.</param>
/// <param name="query">The query object that will be combined with the match query to drive the search</param>
/// <param name="options">Options for the Match request</param>
/// <param name="sourceDocument">The document to generate the search query from</param>
/// <exception cref="TxException">Thrown when an API error occurred</exception>
Task<SearchResponse> MatchJobs(string documentId, Options options);
Task<SearchResponse> MatchJobs(DocumentSource sourceDocument, Options options, SearchQuery query = null);

/// <summary>
/// Search for a job based on the query provided.
Expand Down
16 changes: 9 additions & 7 deletions src/Textkernel.Tx.SDK/Services/MatchV2Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ public async Task<DeleteDocumentsResponse> DeleteJobs(IEnumerable<string> docume
}

/// <inheritdoc />
public async Task<SearchResponse> MatchCandidates(string documentId, Options options)
public async Task<SearchResponse> MatchCandidates(DocumentSource sourceDocument, Options options, SearchQuery query = null)
{
return await MatchInternal(options, ApiEndpoints.MatchV2CandidatesMatchDocument(documentId));
return await MatchInternal(options, query, sourceDocument, ApiEndpoints.MatchV2CandidatesMatchDocument());
}

/// <inheritdoc />
public async Task<SearchResponse> MatchJobs(string documentId, Options options)
public async Task<SearchResponse> MatchJobs(DocumentSource sourceDocument, Options options, SearchQuery query = null)
{
return await MatchInternal(options, ApiEndpoints.MatchV2JobsMatchDocument(documentId));
return await MatchInternal(options, query, sourceDocument, ApiEndpoints.MatchV2JobsMatchDocument());
}

/// <inheritdoc />
Expand All @@ -128,12 +128,14 @@ public async Task<SearchResponse> SearchJobs(SearchQuery query, Options options)
return await SearchInternal(query, options, ApiEndpoints.MatchV2JobsSearch());
}

private async Task<SearchResponse> MatchInternal(Options options, HttpRequestMessage apiRequest)
private async Task<SearchResponse> MatchInternal(Options options, SearchQuery query, DocumentSource sourceDocument, HttpRequestMessage apiRequest)
{
var request = new MatchRequest
{
Options = options,
SearchAndMatchEnvironment = _settings.MatchV2Environment
SearchAndMatchEnvironment = _settings.MatchV2Environment,
Query = query,
SourceDocument = sourceDocument,
};

apiRequest.AddJsonBody(request);
Expand All @@ -144,7 +146,7 @@ private async Task<SearchResponse> MatchInternal(Options options, HttpRequestMes

private async Task<SearchResponse> SearchInternal(SearchQuery query, Options options, HttpRequestMessage apiRequest)
{
var request = new Models.API.MatchV2.Request.SearchRequest
var request = new Models.API.MatchV2.Request.MatchRequest
{
Options = options,
Query = query,
Expand Down
2 changes: 1 addition & 1 deletion src/Textkernel.Tx.SDK/Textkernel.Tx.SDK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Copyright>Copyright © $([System.DateTime]::UtcNow.Year) Textkernel BV. All rights reserved.</Copyright>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/textkernel/tx-dotnet</PackageProjectUrl>
<Version>4.0.0</Version>
<Version>4.0.1</Version>
<PackageIcon>images\icon.png</PackageIcon>
<PackageIconUrl>https://raw.githubusercontent.com/textkernel/tx-dotnet/master/src/Textkernel.Tx.SDK/icon.png</PackageIconUrl>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
Expand Down