Loading TOC...

MarkLogic Server 11.0 Product Documentation
cts.documentFragmentQuery

cts.documentFragmentQuery(
   query as cts.query
) as cts.documentFragmentQuery

Summary

Returns a query that matches all documents where $query matches any document fragment. When searching documents, document-properties, or document-locks, this function provides a convenient way to additionally constrain the search against any document fragment.

Parameters
query A query to be matched against any document fragment.

Usage Notes

A document fragment query enables you to cross fragment boundaries in an AND query, as shown in the second example below.

Example

cts.search(
  cts.documentFragmentQuery(
    cts.wordQuery("hello")));

// All documents that contain the word "hello".

Example

// Assume the database contains the following document with a fragment 
// root of <fragment> and URI "fragmented.xml":
//
//   <root>
//     <author>bob</author>
//     <fragment>dog</fragment>
//     <fragment>cat</fragment>
//     <fragment>fish</fragment>
//  </root>

cts.search(
  cts.andQuery((
    cts.documentFragmentQuery('bob'),
    'dog'
  ))
);

// Matches the 'fragmented.xml' document.

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.