Skip to content

Commit

Permalink
Merge pull request #90 from pksprojects/feature/suggestion_support
Browse files Browse the repository at this point in the history
[feat] Search suggestion support
  • Loading branch information
prafsoni committed Dec 25, 2020
2 parents 23ea427 + d8d1702 commit aee190a
Show file tree
Hide file tree
Showing 11 changed files with 2,283 additions and 19 deletions.
5 changes: 5 additions & 0 deletions Sources/ElasticSwift/Requests/SearchRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,7 @@ public struct SearchSource {
public var highlight: Highlight?
public var rescore: [Rescorer]?
public var searchAfter: CodableValue?
public var suggest: SuggestSource?
}

extension SearchSource: Codable {
Expand All @@ -905,6 +906,7 @@ extension SearchSource: Codable {
postFilter = try container.decodeQueryIfPresent(forKey: .postFilter)
highlight = try container.decodeIfPresent(Highlight.self, forKey: .highlight)
searchAfter = try container.decodeIfPresent(CodableValue.self, forKey: .searchAfter)
suggest = try container.decodeIfPresent(SuggestSource.self, forKey: .suggest)

do {
scriptFields = try container.decodeArrayIfPresent(forKey: .scriptFields)
Expand Down Expand Up @@ -957,6 +959,7 @@ extension SearchSource: Codable {
}
}
try container.encodeIfPresent(searchAfter, forKey: .searchAfter)
try container.encodeIfPresent(suggest, forKey: .suggest)
}

enum CodingKeys: String, CodingKey {
Expand All @@ -978,6 +981,7 @@ extension SearchSource: Codable {
case highlight
case rescore
case searchAfter = "search_after"
case suggest
}
}

Expand All @@ -1001,6 +1005,7 @@ extension SearchSource: Equatable {
&& lhs.searchAfter == rhs.searchAfter
&& isEqualQueries(lhs.query, rhs.query)
&& isEqualQueries(lhs.postFilter, rhs.postFilter)
&& lhs.suggest == rhs.suggest
}
}

Expand Down
Loading

0 comments on commit aee190a

Please sign in to comment.