[MarkLogic Dev General] Search results puzzle
jhunter at marklogic.com
Sat Dec 11 15:11:11 PST 2010
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.
On Dec 11, 2010, at 1:26 PM, Jeni Tennison wrote:
> 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:element-attribute-range-query(xs:QName("ukm:Year"), QName("",
> "Value"), "=", 1985),
> QName("", "RestrictExtent"), "E+W")
> I get back a single document (1985 c. 12).
> If I do what I think is the equivalent query:
> cts:element-attribute-value-query(xs:QName("leg:P1group"), QName("",
> "RestrictExtent"), "E+W"),
> )[.//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,
> P.S. MarkLogic v. 4.1-7
> General mailing list
> General at developer.marklogic.com
More information about the General