The problem is the creation of the dDoc.
Sorry, I'm sure it's a stupid question.
Could you post an example how to create a DesignDoc with the fulltext attribute?
I tryed with the DesignDoc class without success.
Thanks,
Tom
The problem is the creation of the dDoc.
Sorry, I'm sure it's a stupid question.Could you post an example how to create a DesignDoc with the fulltext attribute?
I tryed with the DesignDoc class without success.Thanks,
Tom
You can use this with the TouchDB-Android-Lucene instructions on AndroidGrocerySync.
Hi,I am trying to get TouchDB-Lucene working in Android. While I can get the Couch+Lucene query working in my machine independently, I can't get it to work on Android. The search result returns zero documents always.Maybe I am missing something obvious! Any help would be greatly appreciated.This is what I did:0) create Database: "mydb".1) Created a design document<pre>TDServer localServer = new TDServer(<filesDir>);TouchDBHttpClient touchDBHttpClient = new TouchDBHttpClient(localServer);CouchDbInstance dbInstance = new StdCouchDbInstance(touchDBHttpClient);mydb = dbInstance.createConnector("mydb", true);touchDBHttpClient.put("/mydb/_design/records", "{\"fulltext\": " +"{\"byName\": { \"analyzer\":\"NGRAM\"," +"\"index\": \"function(doc) { if (doc.data) { var ret=new Document(); ret.add(doc.data.name); return ret; } return null; } \"}}}");</pre>2) Created a few documents<pre>mydb.create( <someGUID>, new Record("Chris") )....</pre>3) Tried to query using lucene--<pre>lucene = new TDLucene(localServer);TDLuceneRequest req = new TDLuceneRequest();req.setUrl("/local/mydb/_design/records/byName").addParam("q", "Chris").addParam("include_docs", "true").addParam("highlights", "5");lucene.fetch(req, new Callback() { ... } );</pre>Unfortunately, the response object on the callback's onSuccess method always return 0 rows!
I also tried to use "standard analyzer" while querying without success. I have tried to debug the DatabaseIndexer.search(TDLuceneRequest) method, and found that the IndexSearcher returns TopDocs.totalhits always 0.I am using Eclipse JUNO and have tried using both Android 2.2 (api 8) and 4.1 (api 16)! I noticed that on DDMS view, "/mnt/sdcard/indexes" have sub directories, corresponding to the directories "DatabaseIndexer" creates but does not contain any lucene index files. I wonder why? I have given WRITE_EXTERNAL_STORAGE user permission to the app. Below is some log that look strange from logcat.***************************************************************************************************************11-06 14:58:12.550: I/com.github.rnewson.couchdb.lucene.Config(338): Index output goes to: /mnt/sdcard/indexes11-06 14:58:18.170: D/dalvikvm(338): GC_FOR_MALLOC freed 3398 objects / 436936 bytes in 146ms11-06 14:58:21.480: D/dalvikvm(338): GC_FOR_MALLOC freed 4856 objects / 464536 bytes in 117ms11-06 14:58:21.900: D/com.github.rnewson.couchdb.lucene.DatabaseIndexer.events(338): org.apache.lucene.store.NIOFSDirectory@/mnt/sdcard/indexes/774d1ad6-c751-41db-818d-42b088833d8d/8dmlqqj38mht0oas0xqabylqv lockFactory=org.apache.lucene.store.SingleInstanceLockFactory@44f84be8 bumped since to start11-06 14:58:23.510: I/dalvikvm(338): Could not find method java.lang.management.ManagementFactory.getPlatformMBeanServer, referenced from method org.apache.lucene.util.RamUsageEstimator.<clinit>11-06 14:58:23.520: W/dalvikvm(338): VFY: unable to resolve static method 5764: Ljava/lang/management/ManagementFactory;.getPlatformMBeanServer ()Ljavax/management/MBeanServer;11-06 14:58:23.520: D/dalvikvm(338): VFY: replacing opcode 0x71 at 0x01ef11-06 14:58:23.540: D/dalvikvm(338): VFY: dead code 0x01f2-025b in Lorg/apache/lucene/util/RamUsageEstimator;.<clinit> ()V11-06 14:58:24.090: D/com.github.rnewson.couchdb.lucene.DatabaseIndexer.events(338): paths: {_design/records/byName=View[name=_design/records/byName, digest=8dmlqqj38mht0oas0xqabylqv]}11-06 14:58:25.340: D/dalvikvm(338): GC_FOR_MALLOC freed 5011 objects / 325440 bytes in 143ms11-06 14:58:28.940: W/com.github.rnewson.couchdb.lucene.DatabaseIndexer.events(338): c0b6700c-ecf0-4e1a-9d45-7c561d814f7a caused No Context associated with current Thread***************************************************************************************************************