[MarkLogic Dev General] Frequency and Search Results in 3.2
Bilal Khalid
bilal at scholarsportal.info
Thu May 24 10:43:26 PDT 2007
Ian,
Thanks for pointing out the oddness in the query I pasted. I've attempted to
modify the code to fix that as well as another glaring oversight, and
hopefully with a little annotation my question will make more sense. Please
do correct any misconceptions I have at any stage.
(: Say we want to retrieve the top most frequently used keyword tied to the
word "water" from our database. I would do it thusly, using the value
lexicon on the element "kwd" that we've created beforehand. :)
let $q := cts:word-query("water")
let $elem := cts:element-values(xs:QName("kwd"), "",
("frequency-order","fragment-frequency"), $q)[1]
let $freq := cts:frequency($elem)
(: Now, I would like to see all documents in my database that use this
retrieved keyword ($elem). My understanding is that the search I perform
should return the same number of results as is indicated by the frequency of
the keyword $elem. I've attempted this by using a cts:and-query of my
original word-query and a cts:element-query :)
let $cnt := xdmp:estimate(cts:search(doc(), cts:and-query( ($q,
cts:element-query(xs:QName("kwd"), $elem)) ) ))
(: When I compare the two numerical results however, I find that they aren't
the same. The search results tend to be greater than the frequency count :)
return concat ($elem, " (freq: ", $freq, ") (search: ", $cnt, ")")
I think my misunderstanding lies in the query I'm using to perform the
search, so it would be great if I could be pointed in the right direction
with regards to that.
Thanks,
-Bilal
From: Ian Small <ian at marklogic.com>
> Date: May 23, 2007 5:47 PM
> Subject: RE: [MarkLogic Dev General] Frequency and Search Results in 3.2
> To: General Mark Logic Developer Discussion <general at developer.marklogic.com
> >
>
> Bilal -
>
> It's not clear what you're trying to accomplish from the code fragment
> below, since your use of cts:element-query() on QName kwd as a filter to the
> value lexicon on element QName kwd is puzzling to me.
>
> If you'd like to explain what your objective is, we might be able to
> suggest a simpler code fragment, and then address why things do or don't
> match. At a glance, the code fragment you've provided is (sort of) doing
> two different things between the element-values()/frequency call and the
> xdmp:estimate() call. But I'd rather start from your objective than try to
> unwind this code sample.
>
> Cheers
> ian
>
> ------------------------------
> *From:* general-bounces at developer.marklogic.com [mailto:
> general-bounces at developer.marklogic.com] *On Behalf Of *Bilal Khalid
> *Sent:* Wednesday, May 23, 2007 2:40 PM
> *To:* general at developer.marklogic.com
> *Subject:* [MarkLogic Dev General] Frequency and Search Results in 3.2
>
> Hello All,
>
> I've been trying to resolve the frequency count (retrieved through a
> function like cts:element-values) into actual search results in 3.2, but
> the number of results does not match the frequency count. The example below
> shows the query I've been trying out in CQ.
>
> let $elem := cts:element-values(xs:QName("kwd"), "",
> ("frequency-order","fragment-frequency"), cts:element-query(xs:QName("kwd"),
> "water"))[1]
> let $freq := cts:frequency($elem)
> let $cnt := xdmp:estimate(cts:search(doc(),
> cts:element-query(xs:QName("kwd"), $elem)))
> return concat ($elem, " (freq: ", $freq, ") (search: ", $cnt, ")")
>
> Please note that I use cts:element-query in both lexicon and search
> queries. The only difference is that the search parameter in the second
> query is changed to the first item of the results from the lexicon.
>
> -Bilal
>
> _______________________________________________
> General mailing list
> General at developer.marklogic.com
> http://xqzone.com/mailman/listinfo/general
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://xqzone.marklogic.com/pipermail/general/attachments/20070524/83f4a62c/attachment.html
More information about the General
mailing list