/
NSFNanoSearch.html
2544 lines (1446 loc) · 81.3 KB
/
NSFNanoSearch.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="html/html; charset=utf-8" />
<title>NSFNanoSearch Class Reference</title>
<meta id="xcode-display" name="xcode-display" content="render"/>
<meta name="viewport" content="width=550" />
<link rel="stylesheet" type="text/css" href="../css/styles.css" media="all" />
<link rel="stylesheet" type="text/css" media="print" href="../css/stylesPrint.css" />
<meta name="generator" content="appledoc 2.0.5 (build 789)" />
</head>
<body>
<header id="top_header">
<div id="library" class="hideInXcode">
<h1><a id="libraryTitle" href="../index.html">NanoStore 2.6.4 </a></h1>
<a id="developerHome" href="../index.html">Tito Ciuro</a>
</div>
<div id="title" role="banner">
<h1 class="hideInXcode">NSFNanoSearch Class Reference</h1>
</div>
<ul id="headerButtons" role="toolbar">
<li id="toc_button">
<button aria-label="Show Table of Contents" role="checkbox" class="open" id="table_of_contents"><span class="disclosure"></span>Table of Contents</button>
</li>
<li id="jumpto_button" role="navigation">
<select id="jumpTo">
<option value="top">Jump To…</option>
<option value="overview">Overview</option>
<option value="tasks">Tasks</option>
<option value="properties">Properties</option>
<option value="//api/name/attribute"> attribute</option>
<option value="//api/name/attributesToBeReturned"> attributesToBeReturned</option>
<option value="//api/name/bag"> bag</option>
<option value="//api/name/expressions"> expressions</option>
<option value="//api/name/filterClass"> filterClass</option>
<option value="//api/name/groupValues"> groupValues</option>
<option value="//api/name/key"> key</option>
<option value="//api/name/limit"> limit</option>
<option value="//api/name/match"> match</option>
<option value="//api/name/nanoStore"> nanoStore</option>
<option value="//api/name/offset"> offset</option>
<option value="//api/name/sort"> sort</option>
<option value="//api/name/sql"> sql</option>
<option value="//api/name/value"> value</option>
<option value="class_methods">Class Methods</option>
<option value="//api/name/_prepareSQLQueryStringWithKeys:"> + _prepareSQLQueryStringWithKeys:</option>
<option value="//api/name/_querySegmentForAttributeColumnWithValue:matching:valueColumnWithValue:"> + _querySegmentForAttributeColumnWithValue:matching:valueColumnWithValue:</option>
<option value="//api/name/_querySegmentForColumn:value:matching:"> + _querySegmentForColumn:value:matching:</option>
<option value="//api/name/_quoteStrings:joiningWithDelimiter:"> + _quoteStrings:joiningWithDelimiter:</option>
<option value="//api/name/searchWithStore:"> + searchWithStore:</option>
<option value="instance_methods">Instance Methods</option>
<option value="//api/name/JSONDescription"> - JSONDescription</option>
<option value="//api/name/_dataWithKey:attribute:value:matching:"> - _dataWithKey:attribute:value:matching:</option>
<option value="//api/name/_dataWithKey:attribute:value:matching:returning:"> - _dataWithKey:attribute:value:matching:returning:</option>
<option value="//api/name/_dictionaryForKeyPath:value:"> - _dictionaryForKeyPath:value:</option>
<option value="//api/name/_prepareSQLQueryStringWithExpressions:"> - _prepareSQLQueryStringWithExpressions:</option>
<option value="//api/name/_prepareSQLQueryStringWithKey:attribute:value:matching:"> - _prepareSQLQueryStringWithKey:attribute:value:matching:</option>
<option value="//api/name/_preparedSQL"> - _preparedSQL</option>
<option value="//api/name/_resultsFromSQLQuery:"> - _resultsFromSQLQuery:</option>
<option value="//api/name/_retrieveDataAdded:calendarDate:error:"> - _retrieveDataAdded:calendarDate:error:</option>
<option value="//api/name/_retrieveDataWithError:"> - _retrieveDataWithError:</option>
<option value="//api/name/_sortResultsIfApplicable:returnType:"> - _sortResultsIfApplicable:returnType:</option>
<option value="//api/name/aggregateOperation:onAttribute:"> - aggregateOperation:onAttribute:</option>
<option value="//api/name/description"> - description</option>
<option value="//api/name/executeSQL:"> - executeSQL:</option>
<option value="//api/name/executeSQL:returnType:error:"> - executeSQL:returnType:error:</option>
<option value="//api/name/explainSQL:"> - explainSQL:</option>
<option value="//api/name/initWithStore:"> - initWithStore:</option>
<option value="//api/name/reset"> - reset</option>
<option value="//api/name/searchObjectsAdded:date:returnType:error:"> - searchObjectsAdded:date:returnType:error:</option>
<option value="//api/name/searchObjectsWithReturnType:error:"> - searchObjectsWithReturnType:error:</option>
</select>
</li>
</ul>
</header>
<nav id="tocContainer" class="isShowingTOC">
<ul id="toc" role="tree">
<li role="treeitem"><span class="nodisclosure"></span><span class="sectionName"><a href="#overview">Overview</a></span></li>
<li role="treeitem" id="task_treeitem"><span class="nodisclosure"></span><span class="sectionName"><a href="#tasks">Tasks</a></span><ul>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#task_Creating and Initializing a Search">Creating and Initializing a Search</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#task_Searching">Searching</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#task_Resetting Values">Resetting Values</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#task_Private Methods">Private Methods</a></span></li>
</ul></li>
<li role="treeitem" class="children"><span class="disclosure"></span><span class="sectionName"><a href="#properties">Properties</a></span><ul>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/attribute">attribute</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/attributesToBeReturned">attributesToBeReturned</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/bag">bag</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/expressions">expressions</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/filterClass">filterClass</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/groupValues">groupValues</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/key">key</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/limit">limit</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/match">match</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/nanoStore">nanoStore</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/offset">offset</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/sort">sort</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/sql">sql</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/value">value</a></span></li>
</ul></li>
<li role="treeitem" class="children"><span class="disclosure"></span><span class="sectionName"><a href="#class_methods">Class Methods</a></span><ul>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/_prepareSQLQueryStringWithKeys:">_prepareSQLQueryStringWithKeys:</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/_querySegmentForAttributeColumnWithValue:matching:valueColumnWithValue:">_querySegmentForAttributeColumnWithValue:matching:valueColumnWithValue:</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/_querySegmentForColumn:value:matching:">_querySegmentForColumn:value:matching:</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/_quoteStrings:joiningWithDelimiter:">_quoteStrings:joiningWithDelimiter:</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/searchWithStore:">searchWithStore:</a></span></li>
</ul></li>
<li role="treeitem" class="children"><span class="disclosure"></span><span class="sectionName"><a href="#instance_methods">Instance Methods</a></span><ul>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/JSONDescription">JSONDescription</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/_dataWithKey:attribute:value:matching:">_dataWithKey:attribute:value:matching:</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/_dataWithKey:attribute:value:matching:returning:">_dataWithKey:attribute:value:matching:returning:</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/_dictionaryForKeyPath:value:">_dictionaryForKeyPath:value:</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/_prepareSQLQueryStringWithExpressions:">_prepareSQLQueryStringWithExpressions:</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/_prepareSQLQueryStringWithKey:attribute:value:matching:">_prepareSQLQueryStringWithKey:attribute:value:matching:</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/_preparedSQL">_preparedSQL</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/_resultsFromSQLQuery:">_resultsFromSQLQuery:</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/_retrieveDataAdded:calendarDate:error:">_retrieveDataAdded:calendarDate:error:</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/_retrieveDataWithError:">_retrieveDataWithError:</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/_sortResultsIfApplicable:returnType:">_sortResultsIfApplicable:returnType:</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/aggregateOperation:onAttribute:">aggregateOperation:onAttribute:</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/description">description</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/executeSQL:">executeSQL:</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/executeSQL:returnType:error:">executeSQL:returnType:error:</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/explainSQL:">explainSQL:</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/initWithStore:">initWithStore:</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/reset">reset</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/searchObjectsAdded:date:returnType:error:">searchObjectsAdded:date:returnType:error:</a></span></li>
<li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/searchObjectsWithReturnType:error:">searchObjectsWithReturnType:error:</a></span></li>
</ul></li>
</ul>
</nav>
<article>
<div id="contents" class="isShowingTOC" role="main">
<a title="NSFNanoSearch Class Reference" name="top"></a>
<div class="main-navigation navigation-top">
<ul>
<li><a href="../index.html">Index</a></li>
<li><a href="../hierarchy.html">Hierarchy</a></li>
</ul>
</div>
<div id="header">
<div class="section-header">
<h1 class="title title-header">NSFNanoSearch Class Reference</h1>
</div>
</div>
<div id="container">
<div class="section section-specification"><table cellspacing="0"><tbody>
<tr>
<td class="specification-title">Inherits from</td>
<td class="specification-value">NSObject</td>
</tr><tr>
<td class="specification-title">Declared in</td>
<td class="specification-value">NSFNanoSearch.h</td>
</tr>
</tbody></table></div>
<div class="section section-overview">
<a title="Overview" name="overview"></a>
<h2 class="subtitle subtitle-overview">Overview</h2>
<p>@class NSFNanoSearch
* A unit that provides an API to retrieve data from the document store.
*
* The search can be conducted in two ways: programatically via setters or by providing a SQL statement. In both cases,
* it’s necessary to indicate which object type should be returned. The type \link Globals::NSFReturnType NSFReturnType \endlink provides two options: \link Globals::NSFReturnObjects NSFReturnObjects \endlink and \link Globals::NSFReturnKeys NSFReturnKeys \endlink.
*
* – \link Globals::NSFReturnObjects NSFReturnObjects \endlink will return a dictionary with the <a href="#//api/name/key">key</a> of the NanoObject (<a href="#//api/name/key">key</a>) and the NanoObject itself (<a href="#//api/name/value">value</a>).
* – \link Globals::NSFReturnKeys NSFReturnKeys \endlink will return an array of NanoObjects.
*
* @par <b>Some observations about retrieving data</b><br>
*
* Given the following data set:
*
* – Number of dictionaries: 3.956
* – Number of attributes: 593.862
*
* The table describing different timings to perform a simple <a href="#//api/name/value">value</a> search (i.e. ‘Barcelona’) is included below, ordered from fastest to slowest:
*
<em><table border="1" cellpadding="5">
</em><tr>
<em><th>Match type</th>
</em><th>Seconds</th>
<em></tr>
</em><tr><td>Equal to</td><td>0.295</td></tr>
<em><tr><td>Begins with</td><td>0.295</td></tr>
</em><tr><td>Contains</td><td>1.295</td></tr>
<em><tr><td>Contains (insensitive)</td><td>1.339</td></tr>
</em><tr><td>Ends with (insensitive)</td><td>1.341</td></tr>
<em><tr><td>Ends with</td><td>1.351</td></tr>
</em><tr><td>Equal to (insensitive)</td><td>1.890</td></tr>
<em><tr><td>Begins with (insensitive)</td><td>2.412</td></tr>
</em><tr><td>Greater than</td><td>18.246</td></tr>
<em><tr><td>Less than</td><td>27.677</td></tr>
</em></table></p>
<p>@section wherearetheobjects_sec Where are my objects?</p>
<p>While <a href="../Classes/NSFNanoStore.html">NSFNanoStore</a> provides some convenience methods to obtain standard objects (such as objects of type <a href="../Classes/NSFNanoBag.html">NSFNanoBag</a>), the bulk of the search mechanism is handled by NSFNanoSearch.
The steps involved to perform a search are quite simple:</p>
<ul>
<li>1) Instantiate a search object</li>
<li>2) Configure the search via its accessors</li>
<li>3) Obtain the results specifying whether objects or keys should be returned (*)</li>
</ul>
<p>(<em>) Request objects if you’re interested in the data. Otherwise, you should request keys if you need to feed the result to another method, such as <a href="../Classes/NSFNanoStore.html">NSFNanoStore</a>
\link <a href="../Classes/NSFNanoStore.html">NSFNanoStore</a>::removeObjectsWithKeysInArray:error: –(BOOL)removeObjectsWithKeysInArray:(NSArray </em>)theKeys error:(out NSError **)outError \endlink method.</p>
<p>@details <b>Example: finding all objects with the <a href="#//api/name/attribute">attribute</a> ‘LastName’ and <a href="#//api/name/value">value</a> ‘Doe’.</b>
@code
NSFNanoSearch *search = [NSFNanoSearch searchWithStore:nanoStore];</p>
<p>search.<a href="#//api/name/attribute">attribute</a> = @“LastName”;
search.<a href="#//api/name/match">match</a> = NSFEqualTo;
search.<a href="#//api/name/value">value</a> = @“Doe”;</p>
<p>// Returns a dictionary with the UUID of the object (<a href="#//api/name/key">key</a>) and the NanoObject (<a href="#//api/name/value">value</a>).
NSDictionary *searchResults = [search searchObjectsWithReturnType:NSFReturnObjects error:nil];
@endcode</p>
<p>@details <b>Example: removing all objects with the <a href="#//api/name/attribute">attribute</a> ‘LastName’ and <a href="#//api/name/value">value</a> ‘Doe’.</b>
@code
NSFNanoSearch *search = [NSFNanoSearch searchWithStore:nanoStore];</p>
<p>search.<a href="#//api/name/attribute">attribute</a> = @“LastName”;
search.<a href="#//api/name/match">match</a> = NSFEqualTo;
search.<a href="#//api/name/value">value</a> = @“Doe”;</p>
<p>// Returns an array of matching UUIDs
NSArray *matchingKeys = [search searchObjectsWithReturnType:NSFReturnKeys error:nil];</p>
<p>// Remove the NanoObjects matching the selected UUIDs
NSError *outError = nil;
if (YES == [nanoStore removeObjectsWithKeysInArray:matchingKeys error:&outError]) {
NSLog(@“The matching objects have been removed.”);
} else {
NSLog(@“An error has occurred while removing the matching objects. Reason: %@”, [outError localizedDescription]);
}
@endcode</p>
<p>Another cool feature is the possibility to invoke aggregated functions (count, avg, min, max and total) on the search results. Using the search snippet above,
calculating the average salary of all people with last name equal to ‘Doe’ is very easy.</p>
<p>@details <b>Example: calculating the average salary of all objects with the <a href="#//api/name/attribute">attribute</a> ‘LastName’ and <a href="#//api/name/value">value</a> ‘Doe’.</b>
@code
NSFNanoSearch *search = [NSFNanoSearch searchWithStore:nanoStore];</p>
<p>search.<a href="#//api/name/attribute">attribute</a> = @“LastName”;
search.<a href="#//api/name/match">match</a> = NSFEqualTo;
search.<a href="#//api/name/value">value</a> = @“Doe”;</p>
<p>float averageSalary = [[search aggregateOperation:NSFAverage onAttribute:@“Salary”]floatValue];
@endcode</p>
<ul>
<li>@details <b>Example:</b>
@code
// Instantiate a NanoStore and open it
<a href="../Classes/NSFNanoStore.html">NSFNanoStore</a> *<a href="#//api/name/nanoStore">nanoStore</a> = [<a href="../Classes/NSFNanoStore.html">NSFNanoStore</a> createAndOpenStoreWithType:NSFMemoryStoreType path:nil error:nil];</li>
</ul>
<p>// Generate a NanoObject with a dictionary and a <a href="#//api/name/key">key</a>
NSString <em><a href="#//api/name/key">key</a> = @“ABC-123”;
NSDictionary </em>info = …;
<a href="../Classes/NSFNanoObject.html">NSFNanoObject</a> *nanoObject = [NSFNanoObject nanoObjectWithDictionary:info];</p>
<p>// Add it to the document store
[<a href="#//api/name/nanoStore">nanoStore</a> addObject:nanoObject error:nil];</p>
<p>// Instantiate a search and specify the <a href="#//api/name/attribute">attribute</a>(s) we want to search for
NSFNanoSearch *search = [NSFNanoSearch searchWithStore:nanoStore];
search.<a href="#//api/name/key">key</a> = <a href="#//api/name/key">key</a>;</p>
<p>// Perform the search and obtain the results
NSDictionary *searchResults = [search searchObjectsWithReturnType:NSFReturnObjects error:nil];</p>
<p>// Close the document store
[nanoStore closeWithError:nil];
@endcode</p>
<p>\cond</p>
</div>
<div class="section section-tasks">
<a title="Tasks" name="tasks"></a>
<h2 class="subtitle subtitle-tasks">Tasks</h2>
<h3 class="subsubtitle task-title">Other Methods</h3>
<ul class="task-list">
<li>
<span class="tooltip">
<code><a href="#//api/name/nanoStore"> nanoStore</a></code>
<span class="tooltip"><ul>
<li>The document store used for searching.</li>
</ul>
</span>
</span>
<span class="task-item-suffix">property</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/attributesToBeReturned"> attributesToBeReturned</a></code>
<span class="tooltip"><ul>
<li>The set of attributes to be returned on matching objects.</li>
</ul>
</span>
</span>
<span class="task-item-suffix">property</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/key"> key</a></code>
<span class="tooltip"><ul>
<li>The key used for searching.</li>
</ul>
</span>
</span>
<span class="task-item-suffix">property</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/attribute"> attribute</a></code>
<span class="tooltip"><ul>
<li>The attribute used for searching.</li>
</ul>
</span>
</span>
<span class="task-item-suffix">property</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/value"> value</a></code>
<span class="tooltip"><ul>
<li>The value used for searching.</li>
</ul>
</span>
</span>
<span class="task-item-suffix">property</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/match"> match</a></code>
<span class="tooltip"><ul>
<li>The comparison operator used for searching.</li>
</ul>
</span>
</span>
<span class="task-item-suffix">property</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/expressions"> expressions</a></code>
<span class="tooltip"><ul>
<li>The list of <a href="../Classes/NSFNanoExpression.html">NSFNanoExpression</a> objects used for searching.</li>
</ul>
</span>
</span>
<span class="task-item-suffix">property</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/groupValues"> groupValues</a></code>
<span class="tooltip"><ul>
<li>If set to YES, specifying NSFReturnKeys applies the DISTINCT function and groups the values.</li>
</ul>
</span>
</span>
<span class="task-item-suffix">property</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/sql"> sql</a></code>
<span class="tooltip"><ul>
<li>The SQL statement used for searching. Set when <a href="#//api/name/executeSQL:">executeSQL:</a> is invoked.</li>
</ul>
</span>
</span>
<span class="task-item-suffix">property</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/sort"> sort</a></code>
<span class="tooltip"><ul>
<li>The sort holds an array of one or more sort descriptors of type \link <a href="../Classes/NSFNanoSortDescriptor.html">NSFNanoSortDescriptor</a> <a href="../Classes/NSFNanoSortDescriptor.html">NSFNanoSortDescriptor</a> \endlink.</li>
</ul>
</span>
</span>
<span class="task-item-suffix">property</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/filterClass"> filterClass</a></code>
<span class="tooltip"><ul>
<li>The filterClass allows to filter the results based on a specific object class.</li>
</ul>
</span>
</span>
<span class="task-item-suffix">property</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/offset"> offset</a></code>
<span class="tooltip"><ul>
<li>If an expression has an offset clause, then the first M rows are omitted from the result set returned by the search operation and the next N rows are returned, where M and N are the values that the offset and <a href="#//api/name/limit">limit</a> clauses evaluate to, respectively. Or, if the search would return less than M+N rows if it did not have a <a href="#//api/name/limit">limit</a> clause, then the first M rows are skipped and the remaining rows (if any) are returned.</li>
</ul>
</span>
</span>
<span class="task-item-suffix">property</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/limit"> limit</a></code>
<span class="tooltip"><ul>
<li>The limit clause is used to place an upper bound on the number of rows returned by a Search operation.</li>
</ul>
</span>
</span>
<span class="task-item-suffix">property</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/bag"> bag</a></code>
<span class="tooltip"><ul>
<li><a href="#//api/name/limit">limit</a> a Search to a particular bag.</li>
</ul>
</span>
</span>
<span class="task-item-suffix">property</span>
</li>
</ul>
<a title="Creating and Initializing a Search" name="task_Creating and Initializing a Search"></a>
<h3 class="subsubtitle task-title">Creating and Initializing a Search</h3>
<ul class="task-list">
<li>
<span class="tooltip">
<code><a href="#//api/name/searchWithStore:">+ searchWithStore:</a></code>
<span class="tooltip"><p>Creates and returns a search element for a given document store.</p></span>
</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/initWithStore:">– initWithStore:</a></code>
<span class="tooltip"><p>Initializes a newly allocated search element for a given document store.</p></span>
</span>
</li>
</ul>
<a title="Searching" name="task_Searching"></a>
<h3 class="subsubtitle task-title">Searching</h3>
<ul class="task-list">
<li>
<span class="tooltip">
<code><a href="#//api/name/searchObjectsWithReturnType:error:">– searchObjectsWithReturnType:error:</a></code>
<span class="tooltip"><p>Performs a search using the values of the properties.</p></span>
</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/searchObjectsAdded:date:returnType:error:">– searchObjectsAdded:date:returnType:error:</a></code>
<span class="tooltip"><p>Performs a search using the values of the properties before, on or after a given date.</p></span>
</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/aggregateOperation:onAttribute:">– aggregateOperation:onAttribute:</a></code>
<span class="tooltip"><ul>
<li>Returns the result of the aggregate function.</li>
<li>@param theFunctionType is the function type to be applied.</li>
<li>@param theAttribute is the <a href="#//api/name/attribute">attribute</a> used in the function.</li>
<li>@returns An NSNumber containing the result of the aggregate function.</li>
<li>@details <b>Example:</b>
@code</li>
<li><a href="../Classes/NSFNanoStore.html">NSFNanoStore</a> *<a href="#//api/name/nanoStore">nanoStore</a> = [<a href="../Classes/NSFNanoStore.html">NSFNanoStore</a> createAndOpenStoreWithType:NSFMemoryStoreType path:nil error:nil];
*</li>
<li>// Assume we have saved data to the document store</li>
<li>…</li>
<li>…
*</li>
<li>// Get the average for the <a href="#//api/name/attribute">attribute</a> named ‘SomeNumber’</li>
<li>NSFNanoSearch *search = [NSFNanoSearch searchWithStore:nanoStore];</li>
<li>NSNumber *result = [search aggregateOperation:NSFAverage onAttribute:@“SomeNumber”];
@endcode</li>
</ul>
</span>
</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/executeSQL:returnType:error:">– executeSQL:returnType:error:</a></code>
<span class="tooltip"><p>Performs a search with a given SQL statement.</p></span>
</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/executeSQL:">– executeSQL:</a></code>
<span class="tooltip"><p>Performs a search with a given SQL statement.</p></span>
</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/explainSQL:">– explainSQL:</a></code>
<span class="tooltip"><p>Performs an analysis of the given SQL statement.</p></span>
</span>
</li>
</ul>
<a title="Resetting Values" name="task_Resetting Values"></a>
<h3 class="subsubtitle task-title">Resetting Values</h3>
<ul class="task-list">
<li>
<span class="tooltip">
<code><a href="#//api/name/reset">– reset</a></code>
<span class="tooltip"><p>Resets the values to a know, default state.
– <a href="#//api/name/key">key</a> = nil;
– <a href="#//api/name/attribute">attribute</a> = nil;
– <a href="#//api/name/value">value</a> = nil;
– <a href="#//api/name/match">match</a> = NSFContains;
– object type = NSFReturnObjects;
– <a href="#//api/name/groupValues">groupValues</a> = NO;
– attributesReturned = nil;
– type returned = NSFReturnObjects;
– <a href="#//api/name/sql">sql</a> = nil;
– <a href="#//api/name/sort">sort</a> = nil;</p></span>
</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/description">– description</a></code>
<span class="tooltip"><p>Returns a string representation of the search.</p></span>
</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/JSONDescription">– JSONDescription</a></code>
<span class="tooltip"><p>Returns a JSON representation of the search.</p></span>
</span>
</li>
</ul>
<a title="Private Methods" name="task_Private Methods"></a>
<h3 class="subsubtitle task-title">Private Methods</h3>
<ul class="task-list">
<li>
<span class="tooltip">
<code><a href="#//api/name/_retrieveDataWithError:">– _retrieveDataWithError:</a></code>
</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/_dataWithKey:attribute:value:matching:">– _dataWithKey:attribute:value:matching:</a></code>
</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/_dataWithKey:attribute:value:matching:returning:">– _dataWithKey:attribute:value:matching:returning:</a></code>
</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/_retrieveDataAdded:calendarDate:error:">– _retrieveDataAdded:calendarDate:error:</a></code>
</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/_preparedSQL">– _preparedSQL</a></code>
</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/_prepareSQLQueryStringWithKey:attribute:value:matching:">– _prepareSQLQueryStringWithKey:attribute:value:matching:</a></code>
</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/_prepareSQLQueryStringWithExpressions:">– _prepareSQLQueryStringWithExpressions:</a></code>
</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/_resultsFromSQLQuery:">– _resultsFromSQLQuery:</a></code>
</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/_prepareSQLQueryStringWithKeys:">+ _prepareSQLQueryStringWithKeys:</a></code>
</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/_querySegmentForColumn:value:matching:">+ _querySegmentForColumn:value:matching:</a></code>
</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/_querySegmentForAttributeColumnWithValue:matching:valueColumnWithValue:">+ _querySegmentForAttributeColumnWithValue:matching:valueColumnWithValue:</a></code>
</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/_dictionaryForKeyPath:value:">– _dictionaryForKeyPath:value:</a></code>
</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/_quoteStrings:joiningWithDelimiter:">+ _quoteStrings:joiningWithDelimiter:</a></code>
</span>
</li><li>
<span class="tooltip">
<code><a href="#//api/name/_sortResultsIfApplicable:returnType:">– _sortResultsIfApplicable:returnType:</a></code>
</span>
</li>
</ul>
</div>
<div class="section section-methods">
<a title="Properties" name="properties"></a>
<h2 class="subtitle subtitle-methods">Properties</h2>
<div class="section-method">
<a name="//api/name/attribute" title="attribute"></a>
<h3 class="subsubtitle method-title">attribute</h3>
<div class="method-subsection brief-description">
<ul>
<li>The attribute used for searching.</li>
</ul>
</div>
<div class="method-subsection method-declaration"><code>@property (nonatomic, copy, readwrite) NSString *attribute</code></div>
<div class="method-subsection discussion-section">
<h4 class="method-subtitle">Discussion</h4>
<ul>
<li>The attribute used for searching.</li>
</ul>
</div>
<div class="method-subsection declared-in-section">
<h4 class="method-subtitle">Declared In</h4>
<code class="declared-in-ref">NSFNanoSearch.h</code><br />
</div>
</div>
<div class="section-method">
<a name="//api/name/attributesToBeReturned" title="attributesToBeReturned"></a>
<h3 class="subsubtitle method-title">attributesToBeReturned</h3>
<div class="method-subsection brief-description">
<ul>
<li>The set of attributes to be returned on matching objects.</li>
</ul>
</div>
<div class="method-subsection method-declaration"><code>@property (nonatomic, strong, readwrite) NSArray *attributesToBeReturned</code></div>
<div class="method-subsection discussion-section">
<h4 class="method-subtitle">Discussion</h4>
<ul>
<li>The set of attributes to be returned on matching objects.</li>
</ul>
</div>
<div class="method-subsection declared-in-section">
<h4 class="method-subtitle">Declared In</h4>
<code class="declared-in-ref">NSFNanoSearch.h</code><br />
</div>
</div>
<div class="section-method">
<a name="//api/name/bag" title="bag"></a>
<h3 class="subsubtitle method-title">bag</h3>
<div class="method-subsection brief-description">
<ul>
<li><a href="#//api/name/limit">limit</a> a Search to a particular bag.</li>
</ul>
</div>
<div class="method-subsection method-declaration"><code>@property (nonatomic, assign, readwrite) NSFNanoBag *bag</code></div>
<div class="method-subsection discussion-section">
<h4 class="method-subtitle">Discussion</h4>
<ul>
<li><a href="#//api/name/limit">limit</a> a Search to a particular bag.</li>
</ul>
</div>
<div class="method-subsection declared-in-section">
<h4 class="method-subtitle">Declared In</h4>
<code class="declared-in-ref">NSFNanoSearch.h</code><br />
</div>
</div>
<div class="section-method">
<a name="//api/name/expressions" title="expressions"></a>
<h3 class="subsubtitle method-title">expressions</h3>
<div class="method-subsection brief-description">
<ul>
<li>The list of <a href="../Classes/NSFNanoExpression.html">NSFNanoExpression</a> objects used for searching.</li>
</ul>
</div>
<div class="method-subsection method-declaration"><code>@property (nonatomic, strong, readwrite) NSArray *expressions</code></div>
<div class="method-subsection discussion-section">
<h4 class="method-subtitle">Discussion</h4>
<ul>
<li>The list of <a href="../Classes/NSFNanoExpression.html">NSFNanoExpression</a> objects used for searching.</li>
</ul>
</div>
<div class="method-subsection declared-in-section">
<h4 class="method-subtitle">Declared In</h4>
<code class="declared-in-ref">NSFNanoSearch.h</code><br />
</div>