Skip to content

Commit

Permalink
feat: add group_missing_values search parameter, update `MultiSearc…
Browse files Browse the repository at this point in the history
…hCollectionParameters` schema
  • Loading branch information
phiHero committed Aug 20, 2024
1 parent 9eedde9 commit 6a597cd
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Sources/Typesense/Documents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ public struct Documents {
searchQueryParams.append(URLQueryItem(name: "group_limit", value: String(groupLimit)))
}

if let groupMissingValues = searchParameters.groupMissingValues {
searchQueryParams.append(URLQueryItem(name: "group_missing_values", value: String(groupMissingValues)))
}

if let includeFields = searchParameters.includeFields {
searchQueryParams.append(URLQueryItem(name: "include_fields", value: includeFields))
}
Expand Down
10 changes: 9 additions & 1 deletion Sources/Typesense/Models/MultiSearchCollectionParameters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public struct MultiSearchCollectionParameters: Codable {
public var groupBy: String?
/** Maximum number of hits to be returned for every group. If the `group_limit` is set as `K` then only the top K hits in each group are returned in the response. Default: 3 */
public var groupLimit: Int?
/** Setting this parameter to true will place all documents that have a null value in the group_by field, into a single group. Setting this parameter to false, will cause each document with a null value in the group_by field to not be grouped with other documents. Default: true */
public var groupMissingValues: Bool?
/** List of fields from the document to include in the search result */
public var includeFields: String?
/** List of fields from the document to exclude in the search result */
Expand Down Expand Up @@ -117,8 +119,10 @@ public struct MultiSearchCollectionParameters: Codable {
public var stopwords: String?
/** Comma separated string of nested facet fields whose parent object should be returned in facet response. */
public var facetReturnParent: String?
/** The base64 encoded audio file in 16 khz 16-bit WAV format. */
public var voiceQuery: String?

public init(q: String? = nil, queryBy: String? = nil, queryByWeights: String? = nil, textMatchType: String? = nil, _prefix: String? = nil, _infix: String? = nil, maxExtraPrefix: Int? = nil, maxExtraSuffix: Int? = nil, filterBy: String? = nil, sortBy: String? = nil, facetBy: String? = nil, maxFacetValues: Int? = nil, facetQuery: String? = nil, numTypos: String? = nil, page: Int? = nil, perPage: Int? = nil, limit: Int? = nil, offset: Int? = nil, groupBy: String? = nil, groupLimit: Int? = nil, includeFields: String? = nil, excludeFields: String? = nil, highlightFullFields: String? = nil, highlightAffixNumTokens: Int? = nil, highlightStartTag: String? = nil, highlightEndTag: String? = nil, snippetThreshold: Int? = nil, dropTokensThreshold: Int? = nil, typoTokensThreshold: Int? = nil, pinnedHits: String? = nil, hiddenHits: String? = nil, overrideTags: String? = nil, highlightFields: String? = nil, preSegmentedQuery: Bool? = nil, preset: String? = nil, enableOverrides: Bool? = nil, prioritizeExactMatch: Bool? = nil, prioritizeTokenPosition: Bool? = nil, prioritizeNumMatchingFields: Bool? = nil, enableTyposForNumericalTokens: Bool? = nil, exhaustiveSearch: Bool? = nil, searchCutoffMs: Int? = nil, useCache: Bool? = nil, cacheTtl: Int? = nil, minLen1typo: Int? = nil, minLen2typo: Int? = nil, vectorQuery: String? = nil, remoteEmbeddingTimeoutMs: Int? = nil, remoteEmbeddingNumTries: Int? = nil, collection: String? = nil, facetStrategy: String? = nil, stopwords: String? = nil, facetReturnParent: String? = nil) {
public init(q: String? = nil, queryBy: String? = nil, queryByWeights: String? = nil, textMatchType: String? = nil, _prefix: String? = nil, _infix: String? = nil, maxExtraPrefix: Int? = nil, maxExtraSuffix: Int? = nil, filterBy: String? = nil, sortBy: String? = nil, facetBy: String? = nil, maxFacetValues: Int? = nil, facetQuery: String? = nil, numTypos: String? = nil, page: Int? = nil, perPage: Int? = nil, limit: Int? = nil, offset: Int? = nil, groupBy: String? = nil, groupLimit: Int? = nil, groupMissingValues: Bool? = nil, includeFields: String? = nil, excludeFields: String? = nil, highlightFullFields: String? = nil, highlightAffixNumTokens: Int? = nil, highlightStartTag: String? = nil, highlightEndTag: String? = nil, snippetThreshold: Int? = nil, dropTokensThreshold: Int? = nil, typoTokensThreshold: Int? = nil, pinnedHits: String? = nil, hiddenHits: String? = nil, overrideTags: String? = nil, highlightFields: String? = nil, preSegmentedQuery: Bool? = nil, preset: String? = nil, enableOverrides: Bool? = nil, prioritizeExactMatch: Bool? = nil, prioritizeTokenPosition: Bool? = nil, prioritizeNumMatchingFields: Bool? = nil, enableTyposForNumericalTokens: Bool? = nil, exhaustiveSearch: Bool? = nil, searchCutoffMs: Int? = nil, useCache: Bool? = nil, cacheTtl: Int? = nil, minLen1typo: Int? = nil, minLen2typo: Int? = nil, vectorQuery: String? = nil, remoteEmbeddingTimeoutMs: Int? = nil, remoteEmbeddingNumTries: Int? = nil, collection: String? = nil, facetStrategy: String? = nil, stopwords: String? = nil, facetReturnParent: String? = nil, voiceQuery: String? = nil) {
self.q = q
self.queryBy = queryBy
self.queryByWeights = queryByWeights
Expand All @@ -139,6 +143,7 @@ public struct MultiSearchCollectionParameters: Codable {
self.offset = offset
self.groupBy = groupBy
self.groupLimit = groupLimit
self.groupMissingValues = groupMissingValues
self.includeFields = includeFields
self.excludeFields = excludeFields
self.highlightFullFields = highlightFullFields
Expand Down Expand Up @@ -172,6 +177,7 @@ public struct MultiSearchCollectionParameters: Codable {
self.facetStrategy = facetStrategy
self.stopwords = stopwords
self.facetReturnParent = facetReturnParent
self.voiceQuery = voiceQuery
}

public enum CodingKeys: String, CodingKey {
Expand All @@ -196,6 +202,7 @@ public struct MultiSearchCollectionParameters: Codable {
case offset
case groupBy = "group_by"
case groupLimit = "group_limit"
case groupMissingValues = "group_missing_values"
case includeFields = "include_fields"
case excludeFields = "exclude_fields"
case highlightFullFields = "highlight_full_fields"
Expand Down Expand Up @@ -228,6 +235,7 @@ public struct MultiSearchCollectionParameters: Codable {
case facetStrategy = "facet_strategy"
case stopwords
case facetReturnParent = "facet_return_parent"
case voiceQuery = "voice_query"
}

}
6 changes: 5 additions & 1 deletion Sources/Typesense/Models/MultiSearchParameters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public struct MultiSearchParameters: Codable {
public var groupBy: String?
/** Maximum number of hits to be returned for every group. If the `group_limit` is set as `K` then only the top K hits in each group are returned in the response. Default: 3 */
public var groupLimit: Int?
/** Setting this parameter to true will place all documents that have a null value in the group_by field, into a single group. Setting this parameter to false, will cause each document with a null value in the group_by field to not be grouped with other documents. Default: true */
public var groupMissingValues: Bool?
/** List of fields from the document to include in the search result */
public var includeFields: String?
/** List of fields from the document to exclude in the search result */
Expand Down Expand Up @@ -119,7 +121,7 @@ public struct MultiSearchParameters: Codable {
/** The base64 encoded audio file in 16 khz 16-bit WAV format. */
public var voiceQuery: String?

public init(q: String? = nil, queryBy: String? = nil, queryByWeights: String? = nil, textMatchType: String? = nil, _prefix: String? = nil, _infix: String? = nil, maxExtraPrefix: Int? = nil, maxExtraSuffix: Int? = nil, filterBy: String? = nil, sortBy: String? = nil, facetBy: String? = nil, maxFacetValues: Int? = nil, facetQuery: String? = nil, numTypos: String? = nil, page: Int? = nil, perPage: Int? = nil, limit: Int? = nil, offset: Int? = nil, groupBy: String? = nil, groupLimit: Int? = nil, includeFields: String? = nil, excludeFields: String? = nil, highlightFullFields: String? = nil, highlightAffixNumTokens: Int? = nil, highlightStartTag: String? = nil, highlightEndTag: String? = nil, snippetThreshold: Int? = nil, dropTokensThreshold: Int? = nil, typoTokensThreshold: Int? = nil, pinnedHits: String? = nil, hiddenHits: String? = nil, overrideTags: String? = nil, highlightFields: String? = nil, preSegmentedQuery: Bool? = nil, preset: String? = nil, enableOverrides: Bool? = nil, prioritizeExactMatch: Bool? = nil, prioritizeTokenPosition: Bool? = nil, prioritizeNumMatchingFields: Bool? = nil, enableTyposForNumericalTokens: Bool? = nil, exhaustiveSearch: Bool? = nil, searchCutoffMs: Int? = nil, useCache: Bool? = nil, cacheTtl: Int? = nil, minLen1typo: Int? = nil, minLen2typo: Int? = nil, vectorQuery: String? = nil, remoteEmbeddingTimeoutMs: Int? = nil, remoteEmbeddingNumTries: Int? = nil, facetStrategy: String? = nil, stopwords: String? = nil, facetReturnParent: String? = nil, voiceQuery: String? = nil) {
public init(q: String? = nil, queryBy: String? = nil, queryByWeights: String? = nil, textMatchType: String? = nil, _prefix: String? = nil, _infix: String? = nil, maxExtraPrefix: Int? = nil, maxExtraSuffix: Int? = nil, filterBy: String? = nil, sortBy: String? = nil, facetBy: String? = nil, maxFacetValues: Int? = nil, facetQuery: String? = nil, numTypos: String? = nil, page: Int? = nil, perPage: Int? = nil, limit: Int? = nil, offset: Int? = nil, groupBy: String? = nil, groupLimit: Int? = nil, groupMissingValues: Bool? = nil, includeFields: String? = nil, excludeFields: String? = nil, highlightFullFields: String? = nil, highlightAffixNumTokens: Int? = nil, highlightStartTag: String? = nil, highlightEndTag: String? = nil, snippetThreshold: Int? = nil, dropTokensThreshold: Int? = nil, typoTokensThreshold: Int? = nil, pinnedHits: String? = nil, hiddenHits: String? = nil, overrideTags: String? = nil, highlightFields: String? = nil, preSegmentedQuery: Bool? = nil, preset: String? = nil, enableOverrides: Bool? = nil, prioritizeExactMatch: Bool? = nil, prioritizeTokenPosition: Bool? = nil, prioritizeNumMatchingFields: Bool? = nil, enableTyposForNumericalTokens: Bool? = nil, exhaustiveSearch: Bool? = nil, searchCutoffMs: Int? = nil, useCache: Bool? = nil, cacheTtl: Int? = nil, minLen1typo: Int? = nil, minLen2typo: Int? = nil, vectorQuery: String? = nil, remoteEmbeddingTimeoutMs: Int? = nil, remoteEmbeddingNumTries: Int? = nil, facetStrategy: String? = nil, stopwords: String? = nil, facetReturnParent: String? = nil, voiceQuery: String? = nil) {
self.q = q
self.queryBy = queryBy
self.queryByWeights = queryByWeights
Expand All @@ -140,6 +142,7 @@ public struct MultiSearchParameters: Codable {
self.offset = offset
self.groupBy = groupBy
self.groupLimit = groupLimit
self.groupMissingValues = groupMissingValues
self.includeFields = includeFields
self.excludeFields = excludeFields
self.highlightFullFields = highlightFullFields
Expand Down Expand Up @@ -196,6 +199,7 @@ public struct MultiSearchParameters: Codable {
case offset
case groupBy = "group_by"
case groupLimit = "group_limit"
case groupMissingValues = "group_missing_values"
case includeFields = "include_fields"
case excludeFields = "exclude_fields"
case highlightFullFields = "highlight_full_fields"
Expand Down
6 changes: 5 additions & 1 deletion Sources/Typesense/Models/SearchParameters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public struct SearchParameters: Codable {
public var groupBy: String?
/** Maximum number of hits to be returned for every group. If the `group_limit` is set as `K` then only the top K hits in each group are returned in the response. Default: 3 */
public var groupLimit: Int?
/** Setting this parameter to true will place all documents that have a null value in the group_by field, into a single group. Setting this parameter to false, will cause each document with a null value in the group_by field to not be grouped with other documents. Default: true */
public var groupMissingValues: Bool?
/** List of fields from the document to include in the search result */
public var includeFields: String?
/** List of fields from the document to exclude in the search result */
Expand Down Expand Up @@ -124,7 +126,7 @@ public struct SearchParameters: Codable {
/** The base64 encoded audio file in 16 khz 16-bit WAV format. */
public var voiceQuery: String?

public init(q: String? = nil, queryBy: String? = nil, queryByWeights: String? = nil, textMatchType: String? = nil, _prefix: String? = nil, _infix: String? = nil, maxExtraPrefix: Int? = nil, maxExtraSuffix: Int? = nil, filterBy: String? = nil, sortBy: String? = nil, facetBy: String? = nil, maxFacetValues: Int? = nil, facetQuery: String? = nil, numTypos: String? = nil, page: Int? = nil, perPage: Int? = nil, limit: Int? = nil, offset: Int? = nil, groupBy: String? = nil, groupLimit: Int? = nil, includeFields: String? = nil, excludeFields: String? = nil, highlightFullFields: String? = nil, highlightAffixNumTokens: Int? = nil, highlightStartTag: String? = nil, highlightEndTag: String? = nil, enableHighlightV1: Bool? = nil, snippetThreshold: Int? = nil, dropTokensThreshold: Int? = nil, typoTokensThreshold: Int? = nil, pinnedHits: String? = nil, hiddenHits: String? = nil, overrideTags: String? = nil, highlightFields: String? = nil, splitJoinTokens: String? = nil, preSegmentedQuery: Bool? = nil, preset: String? = nil, enableOverrides: Bool? = nil, prioritizeExactMatch: Bool? = nil, maxCandidates: Int? = nil, prioritizeTokenPosition: Bool? = nil, prioritizeNumMatchingFields: Bool? = nil, enableTyposForNumericalTokens: Bool? = nil, exhaustiveSearch: Bool? = nil, searchCutoffMs: Int? = nil, useCache: Bool? = nil, cacheTtl: Int? = nil, minLen1typo: Int? = nil, minLen2typo: Int? = nil, vectorQuery: String? = nil, remoteEmbeddingTimeoutMs: Int? = nil, remoteEmbeddingNumTries: Int? = nil, facetStrategy: String? = nil, stopwords: String? = nil, facetReturnParent: String? = nil, voiceQuery: String? = nil) {
public init(q: String? = nil, queryBy: String? = nil, queryByWeights: String? = nil, textMatchType: String? = nil, _prefix: String? = nil, _infix: String? = nil, maxExtraPrefix: Int? = nil, maxExtraSuffix: Int? = nil, filterBy: String? = nil, sortBy: String? = nil, facetBy: String? = nil, maxFacetValues: Int? = nil, facetQuery: String? = nil, numTypos: String? = nil, page: Int? = nil, perPage: Int? = nil, limit: Int? = nil, offset: Int? = nil, groupBy: String? = nil, groupLimit: Int? = nil, groupMissingValues: Bool? = nil, includeFields: String? = nil, excludeFields: String? = nil, highlightFullFields: String? = nil, highlightAffixNumTokens: Int? = nil, highlightStartTag: String? = nil, highlightEndTag: String? = nil, enableHighlightV1: Bool? = nil, snippetThreshold: Int? = nil, dropTokensThreshold: Int? = nil, typoTokensThreshold: Int? = nil, pinnedHits: String? = nil, hiddenHits: String? = nil, overrideTags: String? = nil, highlightFields: String? = nil, splitJoinTokens: String? = nil, preSegmentedQuery: Bool? = nil, preset: String? = nil, enableOverrides: Bool? = nil, prioritizeExactMatch: Bool? = nil, maxCandidates: Int? = nil, prioritizeTokenPosition: Bool? = nil, prioritizeNumMatchingFields: Bool? = nil, enableTyposForNumericalTokens: Bool? = nil, exhaustiveSearch: Bool? = nil, searchCutoffMs: Int? = nil, useCache: Bool? = nil, cacheTtl: Int? = nil, minLen1typo: Int? = nil, minLen2typo: Int? = nil, vectorQuery: String? = nil, remoteEmbeddingTimeoutMs: Int? = nil, remoteEmbeddingNumTries: Int? = nil, facetStrategy: String? = nil, stopwords: String? = nil, facetReturnParent: String? = nil, voiceQuery: String? = nil) {
self.q = q
self.queryBy = queryBy
self.queryByWeights = queryByWeights
Expand All @@ -145,6 +147,7 @@ public struct SearchParameters: Codable {
self.offset = offset
self.groupBy = groupBy
self.groupLimit = groupLimit
self.groupMissingValues = groupMissingValues
self.includeFields = includeFields
self.excludeFields = excludeFields
self.highlightFullFields = highlightFullFields
Expand Down Expand Up @@ -204,6 +207,7 @@ public struct SearchParameters: Codable {
case offset
case groupBy = "group_by"
case groupLimit = "group_limit"
case groupMissingValues = "group_missing_values"
case includeFields = "include_fields"
case excludeFields = "exclude_fields"
case highlightFullFields = "highlight_full_fields"
Expand Down
5 changes: 4 additions & 1 deletion Sources/Typesense/MultiSearch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public struct MultiSearch {
searchQueryParams.append(URLQueryItem(name: "offset", value: String(offset)))
}


if let groupBy = commonParameters.groupBy {
searchQueryParams.append(URLQueryItem(name: "group_by", value: groupBy))
}
Expand All @@ -95,6 +94,10 @@ public struct MultiSearch {
searchQueryParams.append(URLQueryItem(name: "group_limit", value: String(groupLimit)))
}

if let groupMissingValues = commonParameters.groupMissingValues {
searchQueryParams.append(URLQueryItem(name: "group_missing_values", value: String(groupMissingValues)))
}

if let includeFields = commonParameters.includeFields {
searchQueryParams.append(URLQueryItem(name: "include_fields", value: includeFields))
}
Expand Down

0 comments on commit 6a597cd

Please sign in to comment.