Giter VIP home page Giter VIP logo

brfulltextsearch's Introduction

FullTextSearch

iOS Objective-C full-text search engine.

This project provides a way to integrate full-text search capabilities into your iOS project. First, it provides a protocol-based API for a simple text indexing and search framework. Second, it provides a CLucene based implementation of that framework.

Example Usage

The following snippet shows how the API works. The CLuceneSearchService reference is the only CLucene-specific portion of the code:

id<BRSearchService> service = [[CLuceneSearchService alloc] initWithIndexPath:@"/some/path"];

// add a document to the index
id<BRIndexable> doc = [[BRSimpleIndexable alloc] initWithIdentifier:@"1" data:@{
					   kBRSearchFieldNameTitle : @"Special document",
					   kBRSearchFieldNameValue : @"This is a long winded note with really important details in it."
					   }];
NSError *error = nil;
[service addObjectToIndexAndWait:doc error:&error];

// search for documents and log contents of each result
id<BRSearchResults> results = [service search:@"special"];
[results iterateWithBlock:^(NSUInteger index, id<BRSearchResult>result, BOOL *stop) {
	NSLog(@"Found result: %@", [result dictionaryRepresentation]);
}];

Core Data integration

It's pretty easy to integrate BRFullTextSearch with Core Data, to maintain a search index while changes are persisted in Core Data. One way is to listen for the NSManagedObjectContextDidSaveNotification notification and process Core Data changes as index delete and update operations. The SampleCoreDataProject project contains an example of this integration. The app allows you to create small sticky notes and search the text of those notes. See the CoreDataManager class in the sample project, whose maintainSearchIndexFromManagedObjectDidSave: method handles this.

Project Setup

After cloning the BRFullTextSearch repository, you must initialize git submodules. For example:

git clone [email protected]:Blue-Rocket/BRFullTextSearch.git
cd BRFullTextSearch
git submodule update --init

This will pull in the relevant submodules, e.g. CLucene.

Static Framework Project Integration

You can integrate BRFullTextSearch into your project in a couple of ways. First, the BRFullTextSearch Xcode project includes a target called BRFullTextSearch.framework that builds a static library framework. Build that target, which will produce a BRFullTextSearch.framework bundle at the root project directory. Copy that framework into your project and add it as a build dependency.

You must also add the following linker build dependencies, which you can do by clicking the + button in the Link Binary With Libraries section of the Build Phases tab in the project settings:

  • libz
  • libstdc++

Next, add -ObjC as an Other Linker Flags build setting.

Finally, you'll need to add the path to the directory containing the BRFullTextSearch.framework bundle as a Framework Search Paths value in the Build Settings tab of the project settings.

The SampleStaticLibraryProject included in this repository is an example project set up using the static library framework integration approach. You must build BRFullTextSearch.framework first, then open this project. When you run the project, it will index a set of documents using some Latin text. You can then search for latin words using a simple UI.

Dependent Project Integration

The other way you can integrate BRFullTextSearch into your project is to add the BRFullTextSearch Xcode project as a dependent project of your project. The BRFullTextSearch Xcode project includes a target called BRFullTextSearch that builds a static library. You can use that target as a dependency in your own project.

To do this, drag the BRFullTextSearch.xcodeproj onto your project in the Project Navigator. Then go to the Build Phases tab of your project's settings. Expand the Target Dependencies section and click the + button. You should see the BRFullTextSearch static library target as an available option. Select that and click the Add button.

You must also add the following linker build dependencies, which you can do by clicking the + button in the Link Binary With Libraries section of the Build Phases tab in the project settings:

  • libz
  • libstdc++

Next, add -ObjC as an Other Linker Flags build setting.

Finally, you'll need to add the path to the directory containing the BRFullTextSearch.xcodeproj file as a Header Search Paths value in the Build Settings tab of the project settings. If you have added BRFullTextSearch as a git submodule to your own project, then the path might be something like "$(PROJECT_DIR)/../BRFullTextSearch".

brfulltextsearch's People

Contributors

msqr avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.