CBLView* view = [database viewNamed: @"fullTextSearch_on_note"];
if (!view.mapBlock) {
[view setMapBlock: MAPBLOCK({
if ([doc[@"doc_type"] isEqualToString: @"note"]) {
id date = [doc objectForKey: @"created_at"];
NSString* body = doc[@"text"];
//emit(body,@[date,doc]);
emit(CBLTextKey(body),@[doc["name"],date]);
}
}) reduceBlock: REDUCEBLOCK({
return @(values.count);
})
version: @"5"]; // bump version any time you change the MAPBLOCK body!
}
CBLQuery* query = [view createQuery];
query.fullTextQuery = text;
query.groupLevel = 1;
NSError *err;
CBLQueryEnumerator *allDocument = [query run:&err];
when i want to search some text in all my note(the text property of note NOT the name of note) and group the result by the "name property”