Position lookups should work better than sub-fragments for those queries. To test this I believe you'll have to activate word-positions, element-word-positions, and element-value-positions in the database.
For Q1 try wrapping the sibling terms in cts:element-query. I think that will work, but if it doesn't you should be able to use cts:near-query instead. For Q2, and add positional options to the cts:element-value-co-occurrences call. You'll probably want 'proximity=1', 'ordered', and always put 'country' before 'orgname'. If you want to stick with fragments for some other reason, that duplicate data idea is viable. Or http://docs.marklogic.com/cts:document-fragment-query might help. -- Mike On 26 Aug 2013, at 01:45 , "Whitby, Rob" <[email protected]> wrote: > I could use some help with fragment roots, I've never had to mess with > them before.. here's a sample document: > > <doc> > <content/> > <authors> > <author> > <country>UK</country> > <orgname>A</orgname> > </author> > <author> > <country>UK</country> > <orgname>A</orgname> > </author> > <author> > <country>India</country> > <orgname>C</orgname> > </author> > </authors> > </doc> > > There are range indexes on country and orgname. > > I'm trying to configure fragment roots to enable 2 types of query: > > Q1. search doc nodes with range query on country. > cts:search(/doc, cts:element-range-query(xs:QName("country"), "=", > "UK"), "unfiltered") > > Q2. co-occurrences on country and orgname - in the same author. > cts:element-value-co-occurrences(xs:QName("country"), > xs:QName("orgname")) > > With no fragment roots defined: > Q1. Works as expected > Q2. doesn't restrict matches to within author node, so get pairs (India, > A), (UK, C). > > With fragment roots defined on doc and author: > Q1. Returns 2 results - one for each author fragment > Q2. Works as expected > > Is there any way to make both these queries work unfiltered? Maybe I could > duplicate the authors node but in a different namespace for the fragment > root to do the co-occurrences? Or is there a better way without using > fragment roots? > > Thanks > Rob > > > > _______________________________________________ > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general > _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
