From: Richard G. <ric...@ya...> - 2005-01-20 13:33:42
|
Hi again, Well, I got the FullTextSearch example working. I needed to insert the following lines Properties props = new Properties(); props.put("OPT_LUCENE_ANALYZER", "org.tm4j.topicmap.index.lucene.analyzer"); map.getIndexManager().registerIndexProvider(new LuceneFullTextIndexProvider(props)); before the following line in the FullTextSearch() method. index = (FullTextIndex)map.getIndexManager().getIndex(FullTextIndex.class); I'm just creating the index in memory, so I haven't set the OPT_LUCENE_DIR property. However, what is still confusing me, i is that if I now call the index.isOpen() method to it returns 'true', but, unless I explicity call either the index.open() or index.reindex() methods, I still get a NullPointerException (stack trace below) when I try to use the index with the line: QueryResult result = index.findByText(query, false); Exception in thread "main" java.lang.NullPointerException at org.apache.lucene.store.RAMInputStream.<init>(RAMDirectory.java:237) at org.apache.lucene.store.RAMDirectory.openFile(RAMDirectory.java:199) at org.apache.lucene.index.SegmentInfos.read(SegmentInfos.java:72) at org.apache.lucene.index.IndexReader$1.doBody(IndexReader.java:116) at org.apache.lucene.store.Lock$With.run(Lock.java:148) at org.apache.lucene.index.IndexReader.open(IndexReader.java:111) at org.apache.lucene.search.IndexSearcher.<init>(IndexSearcher.java:80) at org.tm4j.topicmap.index.text.LuceneIndexBase.findByText(LuceneIndexBase.java:113) at mips.genre.topicmaps.FullTextSearch.go(FullTextSearch.java:130) at mips.genre.topicmaps.FullTextSearch.main(FullTextSearch.java:96) I'm note quite sure what's happening, but from looking at the findByText() method in the LuceneIndexBase class source, I would expect to get the message below rather than a NullPointerException if (dir == null) { throw new IndexException( "FullText index not created. Call open before usage"); } Maybe the test 'if (dir == null)' which is also used in the index.isOpen() method, isn't working properly to check whether the index is open? Cheers, Richard. --- Richard Gregory <ric...@ya...> wrote: > Hi, > > I've been trying to run the full text search example provided with TM4J with one of my topic > maps, > but I just get a NullPointerException from the following line in the go() method: > > QueryResult result = index.findByText(query, false); > > The string that I'm searching for is the basename of a topic, which is successfully found by the > BaseNameDataIndex search, so I know it is in the topic map. > > If anyone has any ideas what is going wrong I'd be grateful. > > Cheers, > > Richard. > > > > > > > > > ___________________________________________________________ > ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com > > > ------------------------------------------------------- > The SF.Net email is sponsored by: Beat the post-holiday blues > Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. > It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt > _______________________________________________ > Tm4j-users mailing list > Tm4...@li... > https://lists.sourceforge.net/lists/listinfo/tm4j-users > ___________________________________________________________ ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com |