Hi Christian,
thanks for your quick answer.
Am 16.01.2012 um 14:04 schrieb Christian Grün:
As a result I would like to see
- the number of results
- the time needed for executing the query and
- the results themselves (preferable one by one for adding additional information, reformating, etc., later I will add a second application to annotate each match and update the collection)
The attached perl client may give you the requested results. It creates the result representation directly within XQuery. This way, you'll get better performance, and may be more flexible when working with the evaluated results.
Thanks. I guess, I cannot do everything directly within XQuery, e.g., extending marked elements to continuous marking, to make "<mark>Korb</mark> <mark>geben</mark>" to be "<mark>Korb geben</mark>" -- it will be more important for queries with ftand or ftor.
Next, I'm also using $xquery->bind() for assigning the query terms, as this reduces the danger of risky query strings (e.g. including quotes) that could break your query.
Thanks for this example. I would like to ask some further questions:
How do I create alternatives for the query? If a user types "A B C" and ticks "process as STRING", the query would be:
ft:mark(//*[text() contains text "A B C" using stemming using language "de"][self::*:p or self::*:l])
If the user ticks "process as AND", the query should be:
ft:mark(//*[text() contains text ("A" ftand "B" ftand "C") using stemming using language "de" distance at most 10 words][self::*:p or self::*:l])
I don't know how to process the input-string to create the correct string for 'terms' and how to toggle queries (I would nee the "distance at most 10 words) for discontinuous queries only). Can I handle this by binding other variables, say 'distance' to a value dependent on user input, like:
ft:mark(//*[text() contains text { $term } using stemming using language "de" { $distance }][self::*:p or self::*:l])
How do I display the whole xquery?
Is there a possibility to store the namespace information somewhere else and not have to write it into every query?
Currently, the easiest way is to use wildcards instead of explicitly specifying the namespace. (... /*:element).
Ah, great, this makes everything a lot shorter.
Best
Cerstin