From c3affe206cf0600ac364baef0e211aeafa71cb87 Mon Sep 17 00:00:00 2001 From: ankitgoyalgloballogic Date: Tue, 30 Nov 2021 16:47:40 +0530 Subject: [PATCH 1/2] Search with Facet Parameters --- AlfrescoContent/AlfrescoContent.podspec | 2 +- .../APIs/SearchAPI+SimpleSearch.swift | 14 +++++----- .../Models/AdvanceSearchFilters.swift | 1 - .../Models/GenericBucketBucketInfo.swift | 6 ++--- .../Swaggers/Models/SearchRequest.swift | 27 ++++++++++++------- 5 files changed, 29 insertions(+), 21 deletions(-) diff --git a/AlfrescoContent/AlfrescoContent.podspec b/AlfrescoContent/AlfrescoContent.podspec index bbe6892..4f8eeac 100644 --- a/AlfrescoContent/AlfrescoContent.podspec +++ b/AlfrescoContent/AlfrescoContent.podspec @@ -4,7 +4,7 @@ Pod::Spec.new do |s| s.osx.deployment_target = '10.14' s.tvos.deployment_target = '12.0' s.swift_version = '5.0' - s.version = '0.2.5' + s.version = '0.2.6' s.source = {:git => 'https://github.com/Alfresco/alfresco-ios-swift-api.git', :tag => 'content/'+s.version.to_s} s.authors = {'Alfresco' => 'mobile.alfresco@alfresco.com'} s.license = {:type => 'Apache License Version 2.0', :file => 'AlfrescoContent/LICENSE.md'} diff --git a/AlfrescoContent/AlfrescoContent/Classes/Swaggers/APIs/SearchAPI+SimpleSearch.swift b/AlfrescoContent/AlfrescoContent/Classes/Swaggers/APIs/SearchAPI+SimpleSearch.swift index 8d1fcac..010b4ec 100644 --- a/AlfrescoContent/AlfrescoContent/Classes/Swaggers/APIs/SearchAPI+SimpleSearch.swift +++ b/AlfrescoContent/AlfrescoContent/Classes/Swaggers/APIs/SearchAPI+SimpleSearch.swift @@ -12,7 +12,7 @@ public class SimpleSearchRequest { let maxItems: Int let searchInclude: [SearchInclude] var filterQueries : [String] - + public init(querry: String, parentId: String?, skipCount: Int, @@ -59,9 +59,11 @@ extension SearchAPI { "-QNAME:comment AND -PNAME:'0/wiki'") } - public class func simpleSearch(searchRequest: SimpleSearchRequest, - completion: @escaping ((_ data: ResultSetPaging?,_ error: Error?) -> Void)) { + facetFields: FacetFields?, + facetQueries: FacetQueries?, + facetIntervals: FacetIntervals?, + completion: @escaping ((_ data: ResultSetPaging?,_ error: Error?) -> Void)) { let querry = requestQuery(searchRequest.querry + "*") let paginationRequest = requestPagination(maxItems: searchRequest.maxItems, skipCount: searchRequest.skipCount) @@ -108,9 +110,9 @@ extension SearchAPI { defaults: defaults, localization: nil, filterQueries: filter, - facetQueries: nil, - facetFields: nil, - facetIntervals: nil, + facetQueries: facetQueries, + facetFields: facetFields, + facetIntervals: facetIntervals, pivots: nil, stats: nil, spellcheck: nil, diff --git a/AlfrescoContent/AlfrescoContent/Classes/Swaggers/Models/AdvanceSearchFilters.swift b/AlfrescoContent/AlfrescoContent/Classes/Swaggers/Models/AdvanceSearchFilters.swift index 0bb3702..28bf5ce 100644 --- a/AlfrescoContent/AlfrescoContent/Classes/Swaggers/Models/AdvanceSearchFilters.swift +++ b/AlfrescoContent/AlfrescoContent/Classes/Swaggers/Models/AdvanceSearchFilters.swift @@ -154,7 +154,6 @@ public class Queries: Codable { // MARK: - Facet Intervals public class FacetIntervals: Codable { - var expanded: Bool? var intervals = [Intervals]() } diff --git a/AlfrescoContent/AlfrescoContent/Classes/Swaggers/Models/GenericBucketBucketInfo.swift b/AlfrescoContent/AlfrescoContent/Classes/Swaggers/Models/GenericBucketBucketInfo.swift index 7b670f5..09fa025 100644 --- a/AlfrescoContent/AlfrescoContent/Classes/Swaggers/Models/GenericBucketBucketInfo.swift +++ b/AlfrescoContent/AlfrescoContent/Classes/Swaggers/Models/GenericBucketBucketInfo.swift @@ -15,13 +15,13 @@ public struct GenericBucketBucketInfo: Codable { /** The start of range */ public var start: String? /** Includes values greater or equal to \"start\" */ - public var startInclusive: Bool? + public var startInclusive: String? /** The end of range */ public var end: String? /** Includes values less than or equal to \"end\" */ - public var endInclusive: Bool? + public var endInclusive: String? - public init(start: String?, startInclusive: Bool?, end: String?, endInclusive: Bool?) { + public init(start: String?, startInclusive: String?, end: String?, endInclusive: String?) { self.start = start self.startInclusive = startInclusive self.end = end diff --git a/AlfrescoContent/AlfrescoContent/Classes/Swaggers/Models/SearchRequest.swift b/AlfrescoContent/AlfrescoContent/Classes/Swaggers/Models/SearchRequest.swift index dd125aa..2ae499f 100644 --- a/AlfrescoContent/AlfrescoContent/Classes/Swaggers/Models/SearchRequest.swift +++ b/AlfrescoContent/AlfrescoContent/Classes/Swaggers/Models/SearchRequest.swift @@ -22,9 +22,6 @@ public struct SearchRequest: Codable { public var defaults: RequestDefaults? public var localization: RequestLocalization? public var filterQueries: RequestFilterQueries? - public var facetQueries: RequestFacetQueries? - public var facetFields: RequestFacetFields? - public var facetIntervals: RequestFacetIntervals? public var pivots: [RequestPivot]? public var stats: [RequestStats]? public var spellcheck: RequestSpellcheck? @@ -32,8 +29,11 @@ public struct SearchRequest: Codable { public var limits: RequestLimits? public var highlight: RequestHighlight? public var ranges: [RequestRange]? + public var facetQueries: [Queries]? + public var facetFields: Dictionary? + public var facetIntervals: Dictionary? - public init(query: RequestQuery, paging: RequestPagination?, include: RequestInclude?, includeRequest: Bool?, fields: RequestFields?, sort: RequestSortDefinition?, templates: RequestTemplates?, defaults: RequestDefaults?, localization: RequestLocalization?, filterQueries: RequestFilterQueries?, facetQueries: RequestFacetQueries?, facetFields: RequestFacetFields?, facetIntervals: RequestFacetIntervals?, pivots: [RequestPivot]?, stats: [RequestStats]?, spellcheck: RequestSpellcheck?, scope: RequestScope?, limits: RequestLimits?, highlight: RequestHighlight?, ranges: [RequestRange]?) { + public init(query: RequestQuery, paging: RequestPagination?, include: RequestInclude?, includeRequest: Bool?, fields: RequestFields?, sort: RequestSortDefinition?, templates: RequestTemplates?, defaults: RequestDefaults?, localization: RequestLocalization?, filterQueries: RequestFilterQueries?, facetQueries: FacetQueries?, facetFields: FacetFields?, facetIntervals: FacetIntervals?, pivots: [RequestPivot]?, stats: [RequestStats]?, spellcheck: RequestSpellcheck?, scope: RequestScope?, limits: RequestLimits?, highlight: RequestHighlight?, ranges: [RequestRange]?) { self.query = query self.paging = paging self.include = include @@ -44,9 +44,6 @@ public struct SearchRequest: Codable { self.defaults = defaults self.localization = localization self.filterQueries = filterQueries - self.facetQueries = facetQueries - self.facetFields = facetFields - self.facetIntervals = facetIntervals self.pivots = pivots self.stats = stats self.spellcheck = spellcheck @@ -54,8 +51,18 @@ public struct SearchRequest: Codable { self.limits = limits self.highlight = highlight self.ranges = ranges + + self.facetQueries = facetQueries?.queries + if let facetFields = facetFields { + self.facetFields = ["facets": facetFields.fields] + } else { + self.facetFields = nil + } + + if let facetIntervals = facetIntervals { + self.facetIntervals = ["intervals": facetIntervals.intervals] + } else { + self.facetIntervals = nil + } } - - } - From 4b7ae63a2cab2cf3eb1a932656bb64a4e0731855 Mon Sep 17 00:00:00 2001 From: ankitgoyalgloballogic Date: Thu, 2 Dec 2021 10:55:09 +0530 Subject: [PATCH 2/2] Fixed PR comments --- .../Classes/Swaggers/Models/SearchRequest.swift | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/AlfrescoContent/AlfrescoContent/Classes/Swaggers/Models/SearchRequest.swift b/AlfrescoContent/AlfrescoContent/Classes/Swaggers/Models/SearchRequest.swift index 2ae499f..b1af790 100644 --- a/AlfrescoContent/AlfrescoContent/Classes/Swaggers/Models/SearchRequest.swift +++ b/AlfrescoContent/AlfrescoContent/Classes/Swaggers/Models/SearchRequest.swift @@ -53,16 +53,13 @@ public struct SearchRequest: Codable { self.ranges = ranges self.facetQueries = facetQueries?.queries + self.facetFields = nil if let facetFields = facetFields { self.facetFields = ["facets": facetFields.fields] - } else { - self.facetFields = nil } - + self.facetIntervals = nil if let facetIntervals = facetIntervals { self.facetIntervals = ["intervals": facetIntervals.intervals] - } else { - self.facetIntervals = nil } } }