I know there is the CLucene project, which is a port of Lucene from Java to C. But is there a Lucene wrapper in C/Objective-C similar to PyLucene that uses JNI and and embeds a JavaVM with Lucene in a separate process?
4 Answers
I explored this in some depth after asking this similar question a while back. The answer appears to be "no." I found CLucene as you did. It's got problems. I also found something called LuceneKit which was also mostly a mess. For my project I just mangled up the code from PyLucene just enough to get it working, and then moved on to another project. Unless something else has come along since then, I feel confident saying that No, there's not a pre-existing, serviceable Lucene wrapper out there. Sorry.
-
That's really unfortunate :( What about JCC though? http://lucene.apache.org/pylucene/jcc/index.html It seems to be a wrapper PyLucene itself uses that's written in C++, it seems to me one can just bypass PyLucene and use JCC directly to interact with Lucene, but I could have a wrong understanding of JCC. What do you think? – Tony Dec 24 '11 at 18:20
-
Ooops, just read the question you asked and realized that you did end up going the JCC route. What's your experience with it? Isn't JCC already a lucene wrapper in c? My current impression is that PyLucene wraps around JCC which wraps around Lucene, not sure if that's accurate. – Tony Dec 24 '11 at 18:23
-
1That's pretty accurate. My experience with it was that it was kind of painful. It would be nice if there were a well-done wrapper. While wrapping the JVM/etc provides good in-process/contained compatibility with Lucene, I was left wondering if I shouldn't just run Solr and call out to it from my app. Not an option for iOS, but then again, neither is wrapping the JVM. – ipmcc Dec 24 '11 at 18:52
-
And for the record, I should have said "well-done Objective-C wrapper." JCC is quite well-done, but it's not written in Objective-C. – ipmcc Dec 24 '11 at 19:53
-
How convenient is calling C++ JCC from Objective-C? It seems that it shouldn't be too much trouble, how come it turned out to be painful? On another note, have you tried Apple's SearchKit? – Tony Dec 24 '11 at 20:23
-
Getting things working was not that bad. The challenge comes from the fact that you've got all these different memory management systems coming together. The Java stuff is garbage collected within itself but JCC holds uncollectable references to jobjects. Then you've got C++ with stack objects, and auto_ptrs, etc. And then you're holding onto those C++ objects with Objective-C objects being managed with retain/release. It's not impossible, but it's painful. If you don't care about leaks, it's easy. :) SearchKit? Never tried it. – ipmcc Dec 24 '11 at 21:11
-
Ouch, so you have Garbage collection, retain/release, and manual memory management all stuck together, does seem like quite a nightmare. How bad are the leaks anyways? Did they cause problems for you? – Tony Dec 24 '11 at 21:21
-
1Like I said, you can work it out, but it's non-trivial. Look at it this way: If you started from scratch with Java and Obj-C, you'd still have two uncooperative memory management systems at work, and you'd have to do all the work anyway. So you might as well up that to three and get JCC for free. I just don't want anyone to think this is a free lunch. FWIW, if I had it to do over again, I'd probably either use Solr or CLucene. Some things just aren't worth it. – ipmcc Dec 24 '11 at 22:47
-
Got it. I think I'll go with Apple's SearchKit and forget about code portability for now, using Lucene from Objective-C seems more trouble than its worth – Tony Dec 25 '11 at 18:42
-
I just realized that btw Evernote is using Lucene on Mac OS X to power its search, rather than searchkit. – Tony Jan 26 '12 at 18:05
-
It's hardly surprising that a majorly cross-platform app like Evernote doesn't use a platform specific search technology. – ipmcc Jan 26 '12 at 18:12
-
in particular they are using clucene btw. That said sometimes it is more time consuming and error prone to try to use a single code base for multiple platform than just to write platform specific way for each. I wonder if they sync the search index file themselves tho or reindex every time – Tony Jan 26 '12 at 18:19
You can also look on Ferret - it is ruby wrapper and pure c library for full text searching. Ferret is similar to lucene but it uses own file format for indexing.

- 456
- 5
- 10
-
The unfortunate thing is that it seems to lack active development since the latest commit was from a year ago in Nov. 2010. :( – Tony Dec 24 '11 at 18:21
Since the answer seems to be 'No' I have been looking for different options.
There seems to be an alternative (free for non-commercial apps; $1000k per app for commercial projects).
http://www.locayta.com/iOS-search-engine/locayta-search-mobile/
I have not used it but I just run into it and saw some comments praising this solution.

- 3,909
- 3
- 33
- 55
You can take a look at Lucy, which seems to be exactly what you are looking for:

- 18,515
- 13
- 84
- 125