If your current fragmentation strategy maps well to the way that your 
application reads and updates documents, then it may make sense to copy some 
information down into the sub-fragments.

Alternatively, you could use cts:uris() to get all the document uris that match 
the top-level part of the query, then feed those uris into a 
cts:document-query() that tests the sub-fragments.

-- Mike

On 21 Jun 2011, at 10:05 , Gary Larsen wrote:

> Hi Danny,
>  
> The original $cq was finding results, but removing the 
> document-fragment-query still returns an empty sequence.  If I change 
> cts:element-values to use an element in the document, but not in a fragment, 
> it correctly returns values.
>  
> I had to use fragments in order to load some large documents, but I haven’t 
> figured out how this is effecting my query strategy.
>  
> Thanks,
> gary
>  
>  
> From: [email protected] 
> [mailto:[email protected]] On Behalf OfDanny Sokolsky
> Sent: Tuesday, June 21, 2011 12:37 PM
> To: General MarkLogic Developer Discussion
> Subject: Re: [MarkLogic Dev General] element values in fragments
>  
> Hi Gary,
>  
> I think element-values will give you answers based on fragments, so I don’t 
> think you need that document-fragment-query (which the way you have written 
> it I think causes that query to match nothing).  Something like:
>  
> xquery version "1.0-ml";
> declare default element 
> namespace'http://developer.envisn.com/xmlns/envisn/netvisn/'; 
> 
> let $modelKey := 'i627DE1CC4CF94F73ACAB3D27953C5D3C' 
> 
> let $cq :=
>   cts:and-query((
>     cts:directory-query("/db/netvisn/content/","infinity"),
>     cts:element-value-query(xs:QName("contentKey"), $modelKey, "exact)
>   ))
>               
> cts:element-values(xs:QName("column"),"", ("document"), $cq)          
> 
> Does that work?  What version of MarkLogic are you running?
>  
> -Danny
>  
> From: [email protected] 
> [mailto:[email protected]] On Behalf OfGary Larsen
> Sent: Tuesday, June 21, 2011 9:11 AM
> To: 'General MarkLogic Developer Discussion'
> Subject: [MarkLogic Dev General] element values in fragments
>  
> Hi,
>  
> I’m trying to create a query to return distinct element values.  I’ve done 
> this before but this time the element resides in a document fragment.  In the 
> query below the ‘column’ element is in a fragment so I included the 
> document-fragment-query in the constraining query.
>  
> Something is not correct as an empty sequence is being returned.
>  
> xquery version "1.0-ml";
> declare default element 
> namespace'http://developer.envisn.com/xmlns/envisn/netvisn/'; 
> 
> let $modelKey := 'i627DE1CC4CF94F73ACAB3D27953C5D3C' 
> 
> let $cq :=
>   cts:and-query((
>     cts:directory-query("/db/netvisn/content/","infinity"),
>     cts:element-value-query(xs:QName("contentKey"), $modelKey, "exact"),
>     cts:document-fragment-query(cts:element-value-match(xs:QName("column"), 
> "?"))
>   ))
>               
> let $columns := cts:element-values(xs:QName("column"),"", (), $cq)          
> for $column in $columns return $column
> 
> This query does return values though:
>  
> return cts:search(doc(), $cq)//column
>  
> <column 
> xmlns="http://developer.envisn.com/xmlns/envisn/netvisn/";>CITY</column>
> <column 
> xmlns="http://developer.envisn.com/xmlns/envisn/netvisn/";>COMPANYNAME</column>
> <column 
> xmlns="http://developer.envisn.com/xmlns/envisn/netvisn/";>COUNTRY</column>
> <column 
> xmlns="http://developer.envisn.com/xmlns/envisn/netvisn/";>REGIONID</column>
> <column 
> xmlns="http://developer.envisn.com/xmlns/envisn/netvisn/";>COUNTRY</column>
> <column 
> xmlns="http://developer.envisn.com/xmlns/envisn/netvisn/";>COUNTRY</column>
> <column 
> xmlns="http://developer.envisn.com/xmlns/envisn/netvisn/";>COUNTRY</column>
> <column 
> xmlns="http://developer.envisn.com/xmlns/envisn/netvisn/";>CITY</column>
> 
> Thanks for any assistance,
> gary
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general

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

Reply via email to