Hi Jeremy, It is best if you provide a simple standalone class or a test case that works with with some test data and will reproduce the problem. That way we can track exactly what is happening.
Thank you, Philip On 8 Jul 2011, at 6:08 PM, Jeremy Raes wrote: > Hey, > > I am building an application upon KIM whereby I need to check if a document > already exist in the repository before deciding on adding it. > > To do this, I wrote the following code: > > private boolean itemNotInRepository(Item item){ > assert(item != null); > DocumentQuery query = new DocumentQuery(); > DocumentQueryResult queryResult = null; > try { > String escaped = QueryParser.escape(item.getDescription()); > query.setKeywordRestriction(escaped); > queryResult = this.apiDR.getDocumentIds(query); > } catch (KIMQueryException e) { > e.printStackTrace(); > } > return queryResult.isEmpty(); > } > > > > > > > > > > > > > > > > > > > > > > Because some of the Strings, returned by item.getDescription(), might contain > special characters [mainly "(" and ")"], I added the String escaped = > QueryParser.escape(item.getDescription()) to my code, but nonetheless I get a > KIMQueryException: > > com.ontotext.kim.client.query.KIMQueryException: Lucene special characters in > field name in brackets: [Canalhopper.\(Duur\] > at > com.ontotext.kim.lucene.LuceneDocumentRepositoryImpl.getDocumentIds(LuceneDocumentRepositoryImpl.java:429) > at > com.ontotext.kim.coredb.CachingDocumentRepository.getDocumentIds(CachingDocumentRepository.java:91) > at com.ontotext.kim.coredb.RdfCore.getDocumentIds(RdfCore.java:266) > at > com.ontotext.kim.coredb.CachingDocumentRepository.getDocumentIds(CachingDocumentRepository.java:91) > at sun.reflect.GeneratedMethodAccessor86.invoke(Unknown Source) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) > at > org.openrdf.util.rmirouting.ChannelIfaceImpl.invoke(ChannelIfaceImpl.java:513) > at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) > at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305) > at sun.rmi.transport.Transport$1.run(Transport.java:159) > at java.security.AccessController.doPrivileged(Native Method) > at sun.rmi.transport.Transport.serviceCall(Transport.java:155) > at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535) > at > sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790) > at > sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649) > at > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) > at java.lang.Thread.run(Thread.java:680) > Exception in thread "main" java.lang.NullPointerException > at > knowledgeAcquisition.KIMKnowledgeAcquisition.itemNotInRepository(KIMKnowledgeAcquisition.java:147) > at > knowledgeAcquisition.KIMKnowledgeAcquisition.execute(KIMKnowledgeAcquisition.java:188) > at run.Main.main(Main.java:21) > > > > > > > > > > > > > > > > > > > > > > > > > > > My guess is that KIM pre-checks the query (before processing it with Lucene) > and throws an error when a special character is found -- even though there is > an "\" before the special character. Any suggestions on how I can (1) either > avoid this error or (2) any other methods to check if a document already > exists in the document repository? > > > > Any help is appreciated. Thanks in advanced! > > > > Best regards, > > Jeremy > > _______________________________________________ > Kim-discussion mailing list > Kim-discussion@ontotext.com > http://ontotext.com/mailman/listinfo/kim-discussion
_______________________________________________ Kim-discussion mailing list Kim-discussion@ontotext.com http://ontotext.com/mailman/listinfo/kim-discussion