Skip to content

Commit 53fa726

Browse files
committed
add new Query parameter and method
1 parent 299d46c commit 53fa726

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CHANGELOG
2+
3+
2015-05-04 1.2.0
4+
* new retry logic
5+
* add new parameter on the Query: setMinProximity & setHighlightingTags
6+
* add new method on the Query: resetLocationParameters

Source/Query.swift

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ public class Query : Printable {
7272
/// Defaults to 7.
7373
public var minWordSizeForApprox2: UInt = 7
7474

75+
/// Configure the precision of the proximity ranking criterion. By default, the minimum (and best) proximity value distance between 2 matching words is 1. Setting it to 2 (or 3) would allow 1 (or 2) words to be found between the matching words without degrading the proximity ranking value.
76+
/// Considering the query "javascript framework", if you set minProximity=2 the records "JavaScript framework" and "JavaScript charting framework" will get the same proximity score, even if the second one contains a word between the 2 matching words.
77+
public var minProximity: UInt = 1
78+
7579
/// If true, the result hits will contain ranking information in _rankingInfo attribute.
7680
/// Default to false.
7781
public var getRankingInfo = false
@@ -157,10 +161,15 @@ public class Query : Printable {
157161
/// The list of words that should be considered as optional when found in the query.
158162
public var optionalWords: [String]?
159163

160-
/// List of object attributes you want to use for textual search (must be a subset of the
161-
/// attributesToIndex index setting).
164+
/// List of object attributes you want to use for textual search (must be a subset of the attributesToIndex index setting).
162165
public var restrictSearchableAttributes: [String]?
163166

167+
/// Specify the string that is inserted before the highlighted parts in the query result (default to "<em>").
168+
public var highlightPreTag: String?
169+
170+
/// Specify the string that is inserted after the highlighted parts in the query result (default to "</em>").
171+
public var highlightPostTag: String?
172+
164173
private var aroundLatLongViaIP = false
165174
private var aroundLatLong: String?
166175
private var insideBoundingBox: String?
@@ -232,6 +241,14 @@ public class Query : Printable {
232241
return self
233242
}
234243

244+
/// Reset location parameters (aroundLatLong,insideBoundingBox, aroundLatLongViaIP set to false)
245+
public func resetLocationParameters() -> Query {
246+
aroundLatLong = nil
247+
insideBoundingBox = nil
248+
aroundLatLongViaIP = false
249+
return self
250+
}
251+
235252
/// Return the final query string used in URL.
236253
public func buildURL() -> String {
237254
var url = [String]()
@@ -303,6 +320,9 @@ public class Query : Printable {
303320
if hitsPerPage != 20 && hitsPerPage > 0 {
304321
url.append(Query.encodeForQuery(hitsPerPage, withKey: "hitsPerPage"))
305322
}
323+
if minProximity > 1 {
324+
url.append(Query.encodeForQuery(minProximity, withKey: "minProximity"))
325+
}
306326
if let queryType = queryType {
307327
url.append(Query.encodeForQuery(queryType, withKey: "queryType"))
308328
}
@@ -315,6 +335,10 @@ public class Query : Printable {
315335
if let numericFilters = numericFilters {
316336
url.append(Query.encodeForQuery(numericFilters, withKey: "numericFilters"))
317337
}
338+
if let highlightPreTag = highlightPreTag, highlightPostTag = highlightPostTag {
339+
url.append(Query.encodeForQuery(highlightPreTag, withKey: "highlightPreTag"))
340+
url.append(Query.encodeForQuery(highlightPostTag, withKey: "highlightPostTag"))
341+
}
318342

319343
if let insideBoundingBox = insideBoundingBox {
320344
url.append(insideBoundingBox)

0 commit comments

Comments
 (0)