From 631affc6add9d36810482a0eb6f8373c5c23c086 Mon Sep 17 00:00:00 2001 From: Anthony Oliveri Date: Mon, 10 Dec 2018 14:41:59 -0600 Subject: [PATCH] feat(DiscoveryV1): Add retrievalDetails property to QueryResponse model retrievalDetails uses a new type called RetrievalDetails --- Source/DiscoveryV1/Models/QueryResponse.swift | 6 +++ .../DiscoveryV1/Models/RetrievalDetails.swift | 53 +++++++++++++++++++ .../project.pbxproj | 2 + 3 files changed, 61 insertions(+) create mode 100644 Source/DiscoveryV1/Models/RetrievalDetails.swift diff --git a/Source/DiscoveryV1/Models/QueryResponse.swift b/Source/DiscoveryV1/Models/QueryResponse.swift index 291858fba..889c3c779 100644 --- a/Source/DiscoveryV1/Models/QueryResponse.swift +++ b/Source/DiscoveryV1/Models/QueryResponse.swift @@ -38,6 +38,11 @@ public struct QueryResponse: Codable, Equatable { */ public var sessionToken: String? + /** + An object contain retrieval type information. + */ + public var retrievalDetails: RetrievalDetails? + // Map each property name to the key that shall be used for encoding/decoding. private enum CodingKeys: String, CodingKey { case matchingResults = "matching_results" @@ -46,6 +51,7 @@ public struct QueryResponse: Codable, Equatable { case passages = "passages" case duplicatesRemoved = "duplicates_removed" case sessionToken = "session_token" + case retrievalDetails = "retrieval_details" } } diff --git a/Source/DiscoveryV1/Models/RetrievalDetails.swift b/Source/DiscoveryV1/Models/RetrievalDetails.swift new file mode 100644 index 000000000..2c8e63498 --- /dev/null +++ b/Source/DiscoveryV1/Models/RetrievalDetails.swift @@ -0,0 +1,53 @@ +/** + * Copyright IBM Corporation 2018 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ + +import Foundation + +/** + An object contain retrieval type information. + */ +public struct RetrievalDetails: Codable, Equatable { + + /** + Indentifies the document retrieval strategy used for this query. `relevancy_training` indicates that the results + were returned using a relevancy trained model. `continuous_relevancy_training` indicates that the results were + returned using the continuous relevancy training model created by result feedback analysis. `untrained` means the + results were returned using the standard untrained model. + **Note**: In the event of trained collections being queried, but the trained model is not used to return results, + the **document_retrieval_strategy** will be listed as `untrained`. + */ + public enum DocumentRetrievalStrategy: String { + case untrained = "untrained" + case relevancyTraining = "relevancy_training" + case continuousRelevancyTraining = "continuous_relevancy_training" + } + + /** + Indentifies the document retrieval strategy used for this query. `relevancy_training` indicates that the results + were returned using a relevancy trained model. `continuous_relevancy_training` indicates that the results were + returned using the continuous relevancy training model created by result feedback analysis. `untrained` means the + results were returned using the standard untrained model. + **Note**: In the event of trained collections being queried, but the trained model is not used to return results, + the **document_retrieval_strategy** will be listed as `untrained`. + */ + public var documentRetrievalStrategy: String? + + // Map each property name to the key that shall be used for encoding/decoding. + private enum CodingKeys: String, CodingKey { + case documentRetrievalStrategy = "document_retrieval_strategy" + } + +} diff --git a/WatsonDeveloperCloud.xcodeproj/project.pbxproj b/WatsonDeveloperCloud.xcodeproj/project.pbxproj index ccbacc769..100a2e184 100644 --- a/WatsonDeveloperCloud.xcodeproj/project.pbxproj +++ b/WatsonDeveloperCloud.xcodeproj/project.pbxproj @@ -1098,6 +1098,7 @@ 924EE7E721505D810048C0E5 /* AssistantV2Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AssistantV2Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 92547738216D470F003C2829 /* QueryLarge.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QueryLarge.swift; sourceTree = ""; }; 92547739216D4710003C2829 /* SearchStatus.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchStatus.swift; sourceTree = ""; }; + 926FAD6221BB3B2C00033989 /* RetrievalDetails.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RetrievalDetails.swift; sourceTree = ""; }; 928204BA2124BC1B0013315B /* CreateEventObject.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CreateEventObject.swift; sourceTree = ""; }; 928204BB2124BC1C0013315B /* MetricAggregationResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MetricAggregationResult.swift; sourceTree = ""; }; 928204BC2124BC1C0013315B /* MetricTokenAggregationResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MetricTokenAggregationResult.swift; sourceTree = ""; }; @@ -1766,6 +1767,7 @@ 68AF8ECE206968CC00D552E3 /* QueryResponse.swift */, 68AF8ECD206968CC00D552E3 /* QueryResult.swift */, 68AE2FD120697C2800330836 /* QueryResultMetadata.swift */, + 926FAD6221BB3B2C00033989 /* RetrievalDetails.swift */, 92547739216D4710003C2829 /* SearchStatus.swift */, 682CBD2B209051B90049EE9F /* SegmentSettings.swift */, CADA958F20FCD66500B5BD84 /* Source.swift */,