Hi Geert,
Thanks for the tips!
For now I have achieved the majority of the functionality I need with a
string range index on paragraph and the following query:
for $val in cts:element-value-match(
xs:QName("paragraph"),
fn:concat("*", $q, "*"),
("item-frequency", "frequency-order", "limit=50", "collation=
http://marklogic.com/collation/codepoint"))
return <s:result count="{ cts:frequency($val) }" value="{ $val }"/>
This has the advantage of being very fast, but the downside is that I loose
MLs built-in language knowledge due to the pattern search.
I'll try your suggestion to see if I can get the same kind of performance
from the seach api.
Also this query returns values instead of the nodes, but I can use the value
to retrieve the node when the author picks one of the paragraphs for reuse.
Thanks all for the help!
Kind regards,
Laurens van den Oever
Xopus BV
http://xopus.com
+31 70 4452345
KvK 27301795
Date: Thu, 30 Jul 2009 08:08:01 +0200
From: Geert Josten <[email protected]>
Subject: RE: [MarkLogic Dev General] RE: Sorting by the number of
occurences of a paragraph
To: General Mark Logic Developer Discussion
<[email protected]>
Hi Laurens,
> Now that I have the query running it looks like it doesn't do
> what I need it to do. cts:element-attribute-values does
> return a list of hash-ids for paragraphs, but the query
> searches within the entire fragment. So the result is all
> hash-ids in all fragments that match the query instead of the
> hash-ids of the paragraphs that contain $q. I'm not entirely
> sure how to proceed from here.
Just a quick pointer on this one. Be aware that searching is fragment-based.
That is the reason why it works so fast. The query you pass to cts:search is
applied to all fragments that cover the result of your searchable Xpath
expression. Just to prevent mistakes I always recommend my colleagues to use
something like this:
cts:search(doc(), cts:element-word-query(xs:QName("paragraph"),
$query))//paragraph
Instead of:
cts:search(//paragraph, cts:element-word-query(xs:QName("paragraph"),
$query))
To find the specific paragraphs that contain matches to your query, you will
have to use cts:highlight, and then use Xpath to find all paragraphs that
contain highlighted text..
Kind regards,
Geert
Drs. G.P.H. Josten
Consultant
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general