search.removeConstraint

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

Summary

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.

Parameters
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.

Example

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>' +
 '</options>')).root;

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

// ==>
// "tag:foo AND year:2007"
   
Powered by MarkLogic Server | Terms of Use | Privacy Policy