Hi David,

I am not sure I understand what you are trying to do, but here are a few ideas:

* consider creating a range index on the CONCEPTID element.  Then you can use 
cts:element-values to get all of the unique CONCEPTID values very quickly (and 
you can use the cts:query parameter to constrain it to a cts:query--like a 
cts:directory-query)

* the predicate [CONCEPTID2 = ($d1,$d2)] will return true if *either* value is 
there, I think (not sure) that you wanted both to be there.

* if you know the full path to your elements, that is preferable to using //

-Danny
________________________________________
From: [email protected] 
[[email protected]] On Behalf Of Lee, David 
[[email protected]]
Sent: Friday, December 11, 2009 6:30 PM
To: [email protected]
Subject: [MarkLogic Dev General] Help with co-occurance (?) xquery

If anyone has any suggestions for this I’d love to hear them.

I have a bunch of records (500k+) of elements like this:

<RELATIONSHIP>
    <RELATIONSHIPID>1149315021</RELATIONSHIPID>
    <CONCEPTID1>7826003</CONCEPTID1>
    <RELATIONSHIPTYPE>246456000</RELATIONSHIPTYPE>
    <CONCEPTID2>288526004</CONCEPTID2>
    <CHARACTERISTICTYPE>1</CHARACTERISTICTYPE>
    <REFINABILITY>2</REFINABILITY>
    <RELATIONSHIPGROUP>0</RELATIONSHIPGROUP>
  </RELATIONSHIP>


Given 2 concepts ID’s .. .I want to query for RELATIONSHIP records where
CONCEPTID1 is the same, and CONCEPTID2 matches the 2 ID’s I have.

I also have a ‘master’ record set of <CONCEPT> which lists all the concept ID’s 
if that helps.
I’m trying this nieve xquery ... which hasnt completed yet:

let $d1 := 387494007,
    $d2 := 387458008

for $c in xdmp:directory("/SNOMED/concepts/")//CONCEPT
let $cid := $c/CONCEPTID/string()
return
   xdmp:directory("/SNOMED/relationships/")//RELATIONSHIP[CONCEPTID1 eq 
$cid][CONCEPTID2 = ($d1,$d2)]


I dont think its quite what I’m looking for but its close.
Problem is 10 minutes later it hasnt returned yet.
I’m sure its not using any kind of indexing which is going to be way too slow.
I’m looking at the cts:element-value-co-occurrences

which seems to be very close to what I want but these 2 relationship elements 
dont co-occur within the same fragment.
My next thought is to regenerate the data putting all relationships where 
CONCEPTID1 inside the CONCEPT element which is associated to it.   That’s 
probably a better design anyway ...
but any suggestions on how to query this in a different way very welcome.







----------------------------------------
David A. Lee
Senior Principal Software Engineer
Epocrates, Inc.
[email protected]<mailto:[email protected]>
812-482-5224


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

Reply via email to