Full text search


#1

Hi,

how would I implement/speed up a full text search that counts the number of occurrences? Currently I compute a search query view to do the job:

CBLView* view = [self.database viewNamed: @“search”];
[view setMapBlock: MAPBLOCK({
NSString* text = doc[@“text”];
if ([uppercaseText [[text uppercaseString] containsString:uppercaseSearchText])
emit(text, doc[@"_id"]);
}) version: @“1”];

But this takes quite a while. To count results I run the query and count the results:

CBLQueryEnumerator* result = [query run:&error];
return [result count];

Is there a better way? Regarding the couchbase API (obviously I can introduce additional caching etc.).

Let me rephrase the question into two questions:

1.) Can I define a view based on another view ? (e.g., the first search query was “a” the next is “aa”, so the second one will reduce the number of matches (same applies to sections “all entries with starting with ‘a’” etc.)
2.) Should/can I use full text search https://github.com/couchbase/couchbase-lite-ios/wiki/Full-Text-Search to speed things up (still using version 1.0.3)?

Greetings,

 Ralf