Loading TOC...

qbe.byExample

qbe.byExample(
   example as Item
) as cts.query

Summary

This function transforms a query by example into a cts.query object.

Parameters
example A query by example for matching JSON documents.

Usage Notes

To learn how to specify a query by example, see Searching Using Query By Example in the Search Developer's Guide. Important: The byExample function has the same limitations as the jsearch.byExample function:

The returned cts.query can be passed to a cts.search call, an Optic API prototype.where operation, or any other call that takes a cts.query object.

Example

const qbe = require('/MarkLogic/appservices/search/qbe.xqy');

const query = qbe.byExample({
  title:{$word: 'sawyer'},
  $and:[
    {price:{$ge:  8.00}},
    {price:{$lt: 10.00}}
  ]
});
cts.search(query);
  

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