Menu

#6 tologx/query-engine - probs with value-like

open
nobody
None
5
2005-09-30
2005-09-28
No

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?

Discussion

  • Kal Ahmed

    Kal Ahmed - 2005-09-28

    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

     
  • Kal Ahmed

    Kal Ahmed - 2005-09-28
    • status: open --> pending
     
  • Maximilian Schwinger

    • status: pending --> open
     
  • Maximilian Schwinger

    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)

     
  • Kal Ahmed

    Kal Ahmed - 2005-09-29

    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.

     
  • Kal Ahmed

    Kal Ahmed - 2005-09-29
    • status: open --> pending
     
  • Maximilian Schwinger

    • status: pending --> open
     
  • Maximilian Schwinger

    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 fr the performance-tips, too.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.