Hi Jason,
Thank you for that. It does indeed seem that 4.2's
cts:document-fragment-query() function does the business.
Jeni
On 11 Dec 2010, at 23:11, Jason Hunter wrote:
> Are the two sub-query matches in different fragments? If they are, the XPath
> expression will cross fragment boundaries while the cts:search() won't by
> default.
>
> You could wrap one of the cts:search sub-queries with
> cts:document-fragment-query() which essentially ask cts:search() to do the
> and-query across fragment boundaries, joining internally based on the URI.
> That might work for you.
>
> It's a new feature so please make sure you have the latest version of the
> server. Also, I don't have a lot of practice with it yet, so no guarantees
> this will help. :) And finally, queries run faster if all sub-query
> constraints are in the same fragment.
>
> -jh-
>
> On Dec 11, 2010, at 1:26 PM, Jeni Tennison wrote:
>
>> Hi,
>>
>> I have a problem using the cts:search() facility.
>>
>> I am looking for documents that (a) contain a ukm:Year element whose
>> Value attribute is 1985 and (b) contain a leg:P1group element with a
>> RestrictExtent attribute whose value is 'E+W'.
>>
>> If I do:
>>
>> cts:search(
>> collection('best'),
>> cts:and-query((
>> cts:element-attribute-range-query(xs:QName("ukm:Year"), QName("",
>> "Value"), "=", 1985),
>> cts:element-attribute-value-query(xs:QName("leg:P1group"),
>> QName("", "RestrictExtent"), "E+W")
>> )),
>> 'unfiltered'
>> )/base-uri(.)
>>
>> I get back a single document (1985 c. 12).
>>
>> If I do what I think is the equivalent query:
>>
>> cts:search(
>> collection('best'),
>> cts:element-attribute-value-query(xs:QName("leg:P1group"), QName("",
>> "RestrictExtent"), "E+W"),
>> 'unfiltered'
>> )[.//ukm:Year/@Value = 1985]/base-uri(.)
>>
>> I get back two documents (1985 c. 12 and 1985 c. 67; actually multiple
>> copies of the second because it's an unfiltered search and the relevant
>> document contains several matching P1groups).
>>
>> So two questions:
>>
>> 1. Why is the first query not giving me back the same results as the
>> second query? Is this to do with fragments or something?
>>
>> 2. What would be the most efficient way of performing this search while
>> retaining the accurate results given by the second of the above expressions?
>>
>> Thank you,
>>
>> Jeni
>>
>> P.S. MarkLogic v. 4.1-7
>> _______________________________________________
>> General mailing list
>> [email protected]
>> http://developer.marklogic.com/mailman/listinfo/general
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
>
--
Jeni Tennison
http://www.jenitennison.com
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general