Loading TOC...

qbe:by-example

qbe:by-example(
   $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 XML 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 by-example function has the same limitations as the function:

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

Example

xquery version "1.0-ml";

import module namespace qbe = "http://marklogic.com/appservices/querybyexample"
     at "/MarkLogic/appservices/search/qbe.xqy";

let $query := qbe:by-example(
  <qbe:query>
    <title><qbe:word>sawyer</qbe:word></title>
    <qbe:and>
      <price><qbe:ge>8.00</qbe:ge></price>
      <price><qbe:lt>10.00</qbe:lt></price>
    </qbe:and>
  </qbe:query>
  )
return cts:search(fn:collection(), $query)
  

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