Hi Dave,

To find the number of fragments that contain a word, you can do an estimate of 
the word query for a word from your word lexicon.  For example:

let $word := cts:words()[1] (: let's just try the first one :)
return
xdmp:estimate(cts:search(doc(), cts:word-query($word))

Depending on what you are looking for, you might want some options on your 
cts:word-query, but this is the general idea.  It will return the number of 
fragments for which this query matches, according to the indexes (that is, an 
estimate).

If you wanted to know the number of occurrences in each fragment, you would (I 
think...) have to look at the fragments and count them (using cts:highlight, 
for example).

-Danny


From: [email protected] 
[mailto:[email protected]] On Behalf Of Dave Feldmeier
Sent: Tuesday, June 15, 2010 2:50 PM
To: [email protected]
Subject: [MarkLogic Dev General] Word lexicon - any way to find number of 
occurrences of word or number of fragments that contain the word?

For a given word in a word lexicon, I'd like to know the number of times that 
the word occurs in all fragments. I know that with a range index, I can get the 
number of occurrences for a specific value, but I can't figure out how to do 
something similar with a word lexicon.

Alternatively, I'd be willing to accept the number of fragments that contain 
the given word. I suppose that I could do a search for each word in the word 
lexicon to get the number of fragments that match that word, but it seems like 
an awkward way to do it.

                -Dave


David Feldmeier
Twin Dolphin Software, Inc.
303 Twin Dolphin Drive, Suite 600
Redwood City, CA, 94065
Tel: 650-352-5700
[email protected]
www.twindolphinsoftware.com

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to