Skip to content

Commit c33d063

Browse files
randhir051Michele Longhi
authored and
Michele Longhi
committed
CloudSearch deprecated. CloudQuery Search added
1 parent 2370e31 commit c33d063

File tree

6 files changed

+189
-5
lines changed

6 files changed

+189
-5
lines changed

CloudBoost.xcodeproj/xcuserdata/randhirsingh.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

+32
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,36 @@
22
<Bucket
33
type = "1"
44
version = "2.0">
5+
<Breakpoints>
6+
<BreakpointProxy
7+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
8+
<BreakpointContent
9+
shouldBeEnabled = "Yes"
10+
ignoreCount = "0"
11+
continueAfterRunningActions = "No"
12+
filePath = "../../../../var/folders/_f/_g5lhxxn12jg3g95l6_4b4fc0000gn/T/XcodeMergeSession-2526848c8e894ddc6fa7205b80be64694ddd0d42/MergeDocument-CloudUserTest.swift"
13+
timestampString = "486567704.737252"
14+
startingColumnNumber = "9223372036854775807"
15+
endingColumnNumber = "9223372036854775807"
16+
startingLineNumber = "18"
17+
endingLineNumber = "18">
18+
</BreakpointContent>
19+
</BreakpointProxy>
20+
<BreakpointProxy
21+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
22+
<BreakpointContent
23+
shouldBeEnabled = "No"
24+
ignoreCount = "0"
25+
continueAfterRunningActions = "No"
26+
filePath = "CloudBoostTests/CloudSearchTest.swift"
27+
timestampString = "486656062.941383"
28+
startingColumnNumber = "9223372036854775807"
29+
endingColumnNumber = "9223372036854775807"
30+
startingLineNumber = "629"
31+
endingLineNumber = "629"
32+
landmarkName = "testPhraseSearch()"
33+
landmarkType = "5">
34+
</BreakpointContent>
35+
</BreakpointProxy>
36+
</Breakpoints>
537
</Bucket>

CloudBoost/CloudQuery.swift

+19-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,25 @@ public class CloudQuery{
149149
}
150150

151151
/**
152+
* CloudQuery Search, caseSensitive and diacriticSensitive defaults to false
152153
*
154+
* @param search
155+
* @param language
156+
* @param caseSensitive
157+
* @param diacriticSensitive
158+
*/
159+
public func search(search: String, language: String? = "en", caseSensitive: Bool? = nil, diacriticSensitive: Bool? = nil) {
160+
let textFields = NSMutableDictionary()
161+
162+
textFields["$search"] = search
163+
textFields["$language"] = language
164+
textFields["$caseSensitive"] = caseSensitive
165+
textFields["$diacriticSensitive"] = diacriticSensitive
166+
167+
self.query["$text"] = textFields
168+
}
169+
170+
/**
153171
* CloudQuery Or
154172
*
155173
*
@@ -602,7 +620,7 @@ public class CloudQuery{
602620
query[columnName] = [ "$geoWithin" : [ "$centerSphere": [ geoPoint.getCoordinates(), radius/3963.2] ] ]
603621
}
604622

605-
public func find(callback: (response: CloudBoostResponse)->Void) throws {
623+
public func find(callback: (response: CloudBoostResponse)->Void) {
606624

607625
let params = NSMutableDictionary()
608626
params["query"] = query

CloudBoost/CloudSearch.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import Foundation
1010

11-
public class CloudSearch {
11+
@available(*,deprecated=0.2) public class CloudSearch {
1212
var collectionName: String?
1313
var collectionArray = [String]()
1414
var query = NSMutableDictionary()

CloudBoost/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.0</string>
18+
<string>0.2</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

CloudBoostTests/CloudObjectTest.swift

+1
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,7 @@ class CloudObjectTest: XCTestCase {
921921
let exp = expectationWithDescription("test fetch")
922922
let obj = CloudObject(tableName: "Student")
923923
obj.set("name", value: "RT bathula")
924+
924925

925926
obj.save({resp in
926927
if resp.success {

CloudBoostTests/CloudSearchTest.swift

+135-2
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@ class CloudSearchTest: XCTestCase {
1313

1414
override func setUp() {
1515
super.setUp()
16-
let app = CloudApp.init(appID: "xckzjbmtsbfb", appKey: "345f3324-c73c-4b15-94b5-9e89356c1b4e")
16+
let app = CloudApp.init(appID: "zbzgfbmhvnzf", appKey: "d9c4cdef-7586-4fa2-822b-cb815424d2c8")
1717
app.setIsLogging(true)
18-
app.setMasterKey("f5cc5cb3-ba0d-446d-9e51-e09be23c540d")
18+
app.setMasterKey("2df6d3e7-a695-4ab0-b18a-d37a90af4dc9")
1919
}
2020

2121
override func tearDown() {
2222
// Put teardown code here. This method is called after the invocation of each test method in the class.
2323
super.tearDown()
2424
}
2525

26+
// DEPRECATED SINCE V0.2
27+
/// SCROLL DOWN FOR THE NEW CloudQuery+Search tests
28+
2629
// should get data from server for near function
2730
func testGetNear(){
2831
let exp = expectationWithDescription("should get data from server for near function")
@@ -595,5 +598,135 @@ class CloudSearchTest: XCTestCase {
595598
waitForExpectationsWithTimeout(30, handler: nil)
596599
}
597600

601+
602+
603+
/// MARK
604+
/// NEW un-deprecated tests
605+
606+
/// Saving data for tests
607+
func testSaveData(){
608+
609+
}
610+
611+
// Basic search
612+
func testBasicSearch(){
613+
let exp = expectationWithDescription("basic search")
614+
let query = CloudQuery(tableName: "Table")
615+
query.search("dog")
616+
query.find({ resp in
617+
if let results = resp.object as? [CloudObject] {
618+
print(results)
619+
//returns CloudObjects of fields having string 'dog'
620+
}else{
621+
resp.log()
622+
}
623+
exp.fulfill()
624+
})
625+
waitForExpectationsWithTimeout(30, handler: nil)
626+
}
627+
628+
// Phrases search
629+
func testPhraseSearch(){
630+
let exp = expectationWithDescription("phrases search")
631+
let query = CloudQuery(tableName: "Table")
632+
query.search("three flowers honeybee")
633+
query.find({ resp in
634+
if let results = resp.object as? [CloudObject] {
635+
print(results)
636+
// returns CloudObjects of fields having keywords either of tree OR flowers OR honeybees keywords
637+
}else{
638+
resp.log()
639+
}
640+
exp.fulfill()
641+
})
642+
waitForExpectationsWithTimeout(30, handler: nil)
643+
}
644+
645+
// Exact phrases search
646+
func testExactPhraseSearch(){
647+
let exp = expectationWithDescription("exact phrase search")
648+
let query = CloudQuery(tableName: "Table")
649+
query.search("\"three flowers\"")
650+
query.find({ resp in
651+
if let results = resp.object as? [CloudObject] {
652+
print(results)
653+
// returns CloudObjects of fields having exact phrase "tree flowers"
654+
}else{
655+
resp.log()
656+
}
657+
exp.fulfill()
658+
})
659+
waitForExpectationsWithTimeout(30, handler: nil)
660+
}
661+
662+
// Negation search
663+
func testNegation(){
664+
let exp = expectationWithDescription("negation search")
665+
let query = CloudQuery(tableName: "Table")
666+
query.search("three flowers -honeybee")
667+
query.find({ resp in
668+
if let results = resp.object as? [CloudObject] {
669+
print(results)
670+
// returns CloudObjects of fields having keyword "three" and "flowers" but not "honeybee"
671+
}else{
672+
resp.log()
673+
}
674+
exp.fulfill()
675+
})
676+
waitForExpectationsWithTimeout(30, handler: nil)
677+
}
678+
679+
// Case sensitive search
680+
func testCaseSensitive(){
681+
let exp = expectationWithDescription("case sensitive search")
682+
let query = CloudQuery(tableName: "Table")
683+
query.search("Dog", caseSensitive: true)
684+
query.find({ resp in
685+
if let results = resp.object as? [CloudObject] {
686+
print(results)
687+
// returns appropriate result matching case sensitive words
688+
}else{
689+
resp.log()
690+
}
691+
exp.fulfill()
692+
})
693+
waitForExpectationsWithTimeout(30, handler: nil)
694+
}
695+
696+
// Diacritic Sensitive
697+
// è will not be equal to e
698+
func testDiacriticSensitive(){
699+
let exp = expectationWithDescription("diacritic sensitive search")
700+
let query = CloudQuery(tableName: "Table")
701+
query.search("dôg", diacriticSensitive: true)
702+
query.find({ resp in
703+
if let results = resp.object as? [CloudObject] {
704+
print(results)
705+
// returns []
706+
}else{
707+
resp.log()
708+
}
709+
exp.fulfill()
710+
})
711+
waitForExpectationsWithTimeout(30, handler: nil)
712+
}
713+
714+
// language
715+
func testLanguage(){
716+
let exp = expectationWithDescription("language specific search")
717+
let query = CloudQuery(tableName: "Table")
718+
query.search("algunas", language: "es")
719+
query.find({ resp in
720+
if let results = resp.object as? [CloudObject] {
721+
print(results)
722+
// returns []
723+
}else{
724+
resp.log()
725+
}
726+
exp.fulfill()
727+
})
728+
waitForExpectationsWithTimeout(30, handler: nil)
729+
}
730+
598731

599732
}

0 commit comments

Comments
 (0)