Loading TOC...


   qtext as String,
   ptext as String,
   options as element(search.options)?
) as String?


NOTE: This function is deprecated. This function safely removes a token from query text, ensuring that grammar elements (AND, OR, quotes, parentheses) are handled properly.

qtext The full query text string.
ptext A token to remove from full query text.
options Options to define the search grammar and control the search. See the description for $options for the function search:search.


const search = require('/MarkLogic/appservices/search/search');

const options =
 fn.head(xdmp.unquote('<options xmlns="http://marklogic.com/appservices/search">' +
   '<constraint name="tag">' +
     '<word>' +
      '<element ns="http://widgets-r-us.com" name="tag"/>' +
     '</word>' +
   '</constraint>' +
   '<constraint name="year">' +
     '<value>' +
      '<element ns="http://widgets-r-us.com" name="year"/>' +
     '</value>' +
   '</constraint>' +

search.removeConstraint("tag:foo AND (year:2007 OR year:2008)",
   "year:2008", options);

// ==>
// "tag:foo AND year:2007"

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