Hi Charles, thanks for the quick reply. Yes, you're obviously right, this makes sense, we will try to implement that. Also, will read Jason's paper again! :)
Jakob. cheers, Jakob. On Tue, Jan 8, 2013 at 4:55 PM, Charles Greer <[email protected]> wrote: > Hi Jakob, > > The way to accomplish this kind of thing using cts:search is pretty well > understood right now. Use a "scatter query" or "shotgun OR" technique -- > use cts:values to fetch the identifiers from chapter documents that > interest you (with a subquery as needed) > > Then use the output of that that call as input to a cts:search on book > documents. > > let $vals := cts:values($index-reference-with-book-identifiers, 0, (), > cts:query("for chapters")) > > return cts:search(/, cts:element-range-query(xs:QName("bookid"), "=", > $vals) > > This runs quickly because it's all XQuery on the server. > > > There's no corresponding technique in search API at this time, although > with a custom constraint one could accomplish it. It's on my todo list to > provide examples of this kind of custom code... The technique would be to > make an XQuery module with this kind of code in it, and then define a > custom constraint that would invoke it, so > > book:term-in-chapter > > would put "term-in-chapter" into the first clause above, and then the > extension would return results from the cts:search. > > Hope that helps a little. There's good discussion of this technique in > the "Inside MarkLogic" paper by Jason Hunter. > > Charles > > > > > > On 01/08/2013 07:29 AM, Jakob Fix wrote: > > Hi, > > Is it possible to find documents based on a criteria match on a related > document with the search:search (or cts:search) api ? To explain: > > I have separate documents for books and chapters, where each chapter has a > reference to their parent book via an identifier, and I would like to find > books which contain either a specific term themselves or in one of their > chapters. I can’t seem to find a way with the cts:query to make something > like a left join in SQL. > > thanks, > Jakob. > > > _______________________________________________ > General mailing > [email protected]http://developer.marklogic.com/mailman/listinfo/general > > > -- > Charles Greer > Senior Engineer > MarkLogic [email protected] > Phone: +1 707 408 3277www.marklogic.com > > > _______________________________________________ > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general > >
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
