Loading TOC...

MarkLogic 12 EA 2 Product Documentation
op.fromDocUris

op.fromDocUris(
   query as Object,
   [qualifier as String?]
) as ModifyPlan

Summary

This function matches and returns the uri for documents.

Parameters
query Qualifies a set of documents. The query can be a cts.query or as an array of document URI string literals.
qualifier Specifies a name for qualifying the column names.

Usage Notes

The op.fromDocUris function provides a convenience equivalent to the following:

function fromDocUris(query, qualifier) {
   return op.fromLexicons(
              {uri: cts.uriReference()},
              qualifier,
              op.fragmentIdCol('fragmentId')
              )
          .where(query);
}
  

See Also

Example

// Returns the document uris which contains word 'tiger' in database.
const op = require('/MarkLogic/optic');
op.fromDocUris(cts.wordQuery('tiger', ['case-sensitive']))
  .result();
  

Example

// Returns the document uris if they exist in database.
// Returns [{"uri":"/test/fromDocUris/0.json"},{"uri":"/test/fromDocUris/1.json"},{"uri":"/test/fromDocUris/2.json"}]
const op = require('/MarkLogic/optic');
const docArray = ['/test/fromDocUris/0.json',
                  '/test/fromDocUris/1.json',
                  '/test/fromDocUris/2.json']
op.fromDocUris(docArray)
  .result();
  

Example

// If you have a document which contains a word 'duck', it returns
// {"uri":"/test/fromDocUris/0.json", "newUri":"/test/fromDocUris/0.json", "newDoc":{"desc":"duck"}}
const op = require('/MarkLogic/optic');
op.fromDocUris(cts.wordQuery('duck', ['case-sensitive']))
  .joinDocCols({doc:'newDoc', uri:'newUri'}, op.fragmentIdCol('fragmentId'))
  .orderBy('uri')
  .result()
  

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