From: SourceForge.net <no...@so...> - 2005-09-30 10:16:54
|
Support Requests item #1306968, was opened at 2005-09-28 14:34 Message generated for change (Comment added) made by schwingm You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=391880&aid=1306968&group_id=27895 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None >Status: Open Priority: 5 Submitted By: Maximilian Schwinger (schwingm) Assigned to: Nobody/Anonymous (nobody) Summary: tologx/query-engine - probs with value-like Initial Comment: I try to perform a value-like - query. Therefore I wanted to register a FullTextIndex. My Problem: How can I do this: At first I need an IndexProvider, which I can initialise with my topicMap. After that I have to register the IndexProvider in the TopicMap's IndexManager. How can I get an IndexProvider? ---------------------------------------------------------------------- >Comment By: Maximilian Schwinger (schwingm) Date: 2005-09-30 10:16 Message: Logged In: YES user_id=1055019 Thanks. I modified your query and this one works fine: String queryString="select $TOPIC from value-like($NAME, %1), topic-name($TOPIC, $TOPIC ) ?" Object[] myParams = {"Test"}; myEvaluator.execute(queryString, myParams); Thanks für the performance-tips, too. ---------------------------------------------------------------------- Comment By: Kal Ahmed (kal_ahmed) Date: 2005-09-29 15:26 Message: Logged In: YES user_id=176992 Actually, it looks like this is a bug with the parser that has gone undetected. From inspection of the tolog.g grammar, it looks like the parser only allows a variable or a direct topic reference to go where you have the string value. Unfortunately it also looks like the rest of the supporting infrastructure of the parser doesn't really handle the string either. However, I think that there is a work-around. If you use a placeholder in the query string and then evaluate with the string as a value: So write your query as: select $TOPIC from value-like($NAME, "test"), topic-name($TOPIC, %1) ? Then evaluate with something like: String queryString="select $TOPIC from value-like($NAME, "test"), topic-name($TOPIC, %1) ?" Object[] myParams = {"Test"}; myEvaluator.execute(queryString, myParams); I think that should work, but haven't had chance to check it out. BTW: You should write your queries so that the most specific clause comes first (as I have done above). I am assuming that the value-like clause should match fewer names/occurrences than the topic-name clause (i.e. all names/occs containing the value "test" vs. all names of all topics!) . You should always consider that the evaluator always works from left-to-right using each clause to filter the results from the last one, so if you make your first clause return a smaller result set, the evaluation will be faster. ---------------------------------------------------------------------- Comment By: Maximilian Schwinger (schwingm) Date: 2005-09-29 14:57 Message: Logged In: YES user_id=1055019 Thank you!! So far it's working now. My next problem is to perform a query. I tried to perform this one (from accountingontology.com): select $TOPIC from topic-name($TOPIC, $NAME), value-like ($NAME, "test") ? and get the following stack-trace: org.tm4j.tologx.TologParserException: Error parsing query string. at org.tm4j.tologx.memory.QueryEvaluatorImpl.prepareQuery (QueryEvaluator Impl.java:156) at CommandReceiver.performQuery (CommandReceiver.java:36) at test.main(test.java:41) Caused by: line 1:65: unexpected token: "test" at org.tm4j.tologx.parser.TologParser.expr (TologParser.java:1258) at org.tm4j.tologx.parser.TologParser.pair (TologParser.java:1165) at org.tm4j.tologx.parser.TologParser.predclause (TologParser.java:1099) at org.tm4j.tologx.parser.TologParser.clause (TologParser.java:800) at org.tm4j.tologx.parser.TologParser.clauselist (TologParser.java:457) at org.tm4j.tologx.parser.TologParser.query (TologParser.java:512) at org.tm4j.tologx.memory.QueryEvaluatorImpl.prepareQuery (QueryEvaluator Impl.java:152) ---------------------------------------------------------------------- Comment By: Kal Ahmed (kal_ahmed) Date: 2005-09-28 19:27 Message: Logged In: YES user_id=176992 You need to instantiate the class org.tm4j.topicmap.memory.index.LuceneFullTextIndexProvider, and then pass that instance into the registerIndexProvider method on the IndexManager. Note that you need to pass a Properties instance in to the constructor of the LuceneFullTextIndexProvider. The properties that are recognised are documented in the class org.tm4j.topicmap.index.text.LuceneIndexBase ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=391880&aid=1306968&group_id=27895 |