diff --git a/src/Textkernel.Tx.SDK.Tests/IntegrationTests/MatchV2Tests.cs b/src/Textkernel.Tx.SDK.Tests/IntegrationTests/MatchV2Tests.cs index 6a60f431..45b091ae 100644 --- a/src/Textkernel.Tx.SDK.Tests/IntegrationTests/MatchV2Tests.cs +++ b/src/Textkernel.Tx.SDK.Tests/IntegrationTests/MatchV2Tests.cs @@ -122,20 +122,18 @@ public async Task TestMatch() Assert.ThrowsAsync(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); }); @@ -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); }); diff --git a/src/Textkernel.Tx.SDK.Tests/TestData.cs b/src/Textkernel.Tx.SDK.Tests/TestData.cs index 1cdd6532..d8aa7741 100644 --- a/src/Textkernel.Tx.SDK.Tests/TestData.cs +++ b/src/Textkernel.Tx.SDK.Tests/TestData.cs @@ -78,7 +78,7 @@ Personal Information private static string _jobOrderTextTech = @" Position Title: Sr. Software Developer - +Location: New York, US Skills: JavaScript ReactJS"; diff --git a/src/Textkernel.Tx.SDK/ApiEndpoints.cs b/src/Textkernel.Tx.SDK/ApiEndpoints.cs index 52cdb16b..12ec4a27 100644 --- a/src/Textkernel.Tx.SDK/ApiEndpoints.cs +++ b/src/Textkernel.Tx.SDK/ApiEndpoints.cs @@ -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 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 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"); } } diff --git a/src/Textkernel.Tx.SDK/Models/API/MatchV2/Request/DocumentSource.cs b/src/Textkernel.Tx.SDK/Models/API/MatchV2/Request/DocumentSource.cs new file mode 100644 index 00000000..0a24d82c --- /dev/null +++ b/src/Textkernel.Tx.SDK/Models/API/MatchV2/Request/DocumentSource.cs @@ -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 +{ + /// + /// Defines a document that can be used to generate a match query. + /// + public class DocumentSource + { + /// + /// Specify what type of document is being passed to the match engine. + /// + public DocumentType Type { get; set; } + + /// + /// Id of the document in the index to generate the query from. + /// + public string Id { get; set; } + } +} diff --git a/src/Textkernel.Tx.SDK/Models/API/MatchV2/Request/MatchRequest.cs b/src/Textkernel.Tx.SDK/Models/API/MatchV2/Request/MatchRequest.cs index 833df260..88ba6810 100644 --- a/src/Textkernel.Tx.SDK/Models/API/MatchV2/Request/MatchRequest.cs +++ b/src/Textkernel.Tx.SDK/Models/API/MatchV2/Request/MatchRequest.cs @@ -24,8 +24,18 @@ public class MatchRequest public MatchV2Environment SearchAndMatchEnvironment { get; set; } /// - /// The options for the Search/Match request + /// The options for the Match request /// public Options Options { get; set; } + + /// + /// The query object that will be combined with the match query to drive the search. + /// + public SearchQuery Query { get; set; } + + /// + /// The document to generate the search query from. + /// + public DocumentSource SourceDocument { get; set; } } } diff --git a/src/Textkernel.Tx.SDK/Models/API/MatchV2/Request/Options.cs b/src/Textkernel.Tx.SDK/Models/API/MatchV2/Request/Options.cs index 90f43508..21c94f01 100644 --- a/src/Textkernel.Tx.SDK/Models/API/MatchV2/Request/Options.cs +++ b/src/Textkernel.Tx.SDK/Models/API/MatchV2/Request/Options.cs @@ -126,9 +126,8 @@ public class Options public Sorting[] Sorting { get; set; } /// - /// 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. /// - public DocumentType DocumentType { get; set; } + public bool UseNLQS { get; set; } } } diff --git a/src/Textkernel.Tx.SDK/Models/API/MatchV2/Request/SearchRequest.cs b/src/Textkernel.Tx.SDK/Models/API/MatchV2/Request/SearchRequest.cs index cb5cf61b..e0dac1e1 100644 --- a/src/Textkernel.Tx.SDK/Models/API/MatchV2/Request/SearchRequest.cs +++ b/src/Textkernel.Tx.SDK/Models/API/MatchV2/Request/SearchRequest.cs @@ -6,17 +6,6 @@ namespace Textkernel.Tx.Models.API.MatchV2.Request { - /// - /// Request body for a Search request - /// - public class SearchRequest : MatchRequest - { - /// - /// The query object that will drive the search. - /// - public SearchQuery Query { get; set; } - } - /// /// A search query /// diff --git a/src/Textkernel.Tx.SDK/Services/IMatchV2Service.cs b/src/Textkernel.Tx.SDK/Services/IMatchV2Service.cs index e5663510..b0f0faed 100644 --- a/src/Textkernel.Tx.SDK/Services/IMatchV2Service.cs +++ b/src/Textkernel.Tx.SDK/Services/IMatchV2Service.cs @@ -44,10 +44,11 @@ public interface IMatchV2Service /// /// Match an existing candidate document with filters provided. /// - /// The document id that the user would like to run a match on. + /// The query object that will be combined with the match query to drive the search /// Options for the Match request + /// The document to generate the search query from /// Thrown when an API error occurred - Task MatchCandidates(string documentId, Options options); + Task MatchCandidates(DocumentSource sourceDocument, Options options, SearchQuery query = null); /// /// Search for a candidate based on the query provided. @@ -95,10 +96,11 @@ public interface IMatchV2Service /// /// Match an existing job document with filters provided. /// - /// The document id that the user would like to run a match on. + /// The query object that will be combined with the match query to drive the search /// Options for the Match request + /// The document to generate the search query from /// Thrown when an API error occurred - Task MatchJobs(string documentId, Options options); + Task MatchJobs(DocumentSource sourceDocument, Options options, SearchQuery query = null); /// /// Search for a job based on the query provided. diff --git a/src/Textkernel.Tx.SDK/Services/MatchV2Service.cs b/src/Textkernel.Tx.SDK/Services/MatchV2Service.cs index d4fe5e25..375e1bae 100644 --- a/src/Textkernel.Tx.SDK/Services/MatchV2Service.cs +++ b/src/Textkernel.Tx.SDK/Services/MatchV2Service.cs @@ -105,15 +105,15 @@ public async Task DeleteJobs(IEnumerable docume } /// - public async Task MatchCandidates(string documentId, Options options) + public async Task MatchCandidates(DocumentSource sourceDocument, Options options, SearchQuery query = null) { - return await MatchInternal(options, ApiEndpoints.MatchV2CandidatesMatchDocument(documentId)); + return await MatchInternal(options, query, sourceDocument, ApiEndpoints.MatchV2CandidatesMatchDocument()); } /// - public async Task MatchJobs(string documentId, Options options) + public async Task MatchJobs(DocumentSource sourceDocument, Options options, SearchQuery query = null) { - return await MatchInternal(options, ApiEndpoints.MatchV2JobsMatchDocument(documentId)); + return await MatchInternal(options, query, sourceDocument, ApiEndpoints.MatchV2JobsMatchDocument()); } /// @@ -128,12 +128,14 @@ public async Task SearchJobs(SearchQuery query, Options options) return await SearchInternal(query, options, ApiEndpoints.MatchV2JobsSearch()); } - private async Task MatchInternal(Options options, HttpRequestMessage apiRequest) + private async Task 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); @@ -144,7 +146,7 @@ private async Task MatchInternal(Options options, HttpRequestMes private async Task 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, diff --git a/src/Textkernel.Tx.SDK/Textkernel.Tx.SDK.csproj b/src/Textkernel.Tx.SDK/Textkernel.Tx.SDK.csproj index c937b78e..7952797e 100644 --- a/src/Textkernel.Tx.SDK/Textkernel.Tx.SDK.csproj +++ b/src/Textkernel.Tx.SDK/Textkernel.Tx.SDK.csproj @@ -10,7 +10,7 @@ Copyright © $([System.DateTime]::UtcNow.Year) Textkernel BV. All rights reserved. Apache-2.0 https://github.com/textkernel/tx-dotnet - 4.0.0 + 4.0.1 images\icon.png https://raw.githubusercontent.com/textkernel/tx-dotnet/master/src/Textkernel.Tx.SDK/icon.png true