new options()
Creates a new search options builder connected to this client database connection mljs instance. Each function returns a reference to the option builder object to support chaining.
Methods
-
addConstraint(con)
-
Adds any new constraint JSON to the search options object. Always called by the *Constraint methods themselves anyway. This is for any constraints you wish to add that don't have their own method here.
Parameters:
Name Type Description conJSON Constraint JSON to add to these options.
-
additionalQuery(str)
-
Specifies the additional query to use to filter any search results
Parameters:
Name Type Description strstring The additional query string (XML string of a CTS query) to use
-
annotate(constraint_name, annotation)
-
Add an annotation to a constraint after the constraint has been configured. Useful for lazy loading localised strings.
Parameters:
Name Type Description constraint_namestring the name of the constraint in these options
annotationstring | Array the annotation string, or array of strings
-
buckets(constraint_name)
-
Adds fixed buckets for the specified constraint. Returns a JSON object that has a bucket(lt,ge,name_opt,label_opt) method. Used like this:-
var yearBuckets = ob.buckets(year); yearBuckets.bucket(1920,1929,"1920s","The 1920s").bucket(...).bucket(...);Note: If you don't specify name, MLJS will create a string based on "gevalue-ltvalue". If you don't specify label, it will default to the name specified or calculated by MLJS
Parameters:
Name Type Description constraint_namestring The name of the constraint to define buckets for.
-
collectionConstraint(constraint_name_opt, prefix, facet_option_opt, annotation_opt)
-
Create a collection constraint, and adds it to the search options object
Parameters:
Name Type Description constraint_name_optstring Optional constraint name to use. Defaults to 'collection'
prefixstring Optional prefix (base collection) to use. Defaults to blank ''. I.e. all collections
facet_option_optJSON Optional JSON facet configureation. If not configured, will use the default facet configuration
annotation_optstring | Array The annotation to add to the constraint. MLJS uses annotation[0] as the display title, falling back to camel case constraint name if not specified
-
computedBuckets(constraint_name)
-
Adds Computed buckets for the specified constraint. Returns a JSON object that has a bucket(lt,ge,name_opt,label_opt) method. Used like this:-
var timeBuckets = ob.buckets("updated"); timeBuckets.bucket("P0D","P1D","now","today","Today").bucket(...).bucket(...);Note: If you don't specify name, MLJS will create a string based on "gevalue-ltvalue". If you don't specify label, it will default to the name specified or calculated by MLJS
Parameters:
Name Type Description constraint_namestring The name of the constraint to define buckets for.
-
concurrencyLevel(level)
-
Specified the concurrency level option
Parameters:
Name Type Description levelstring REST API concurrency level to use
-
customConstraint(constraint_name, parsefunction, parsenamesapce, parselibrary, startfunction, startnamesapce, startlibrary, finishfunction, finishnamesapce, finishlibrary, annotation_opt, additional_properties_opt)
-
Defines a custom constraint. To skip one of parse, start or finish, set the function parameter to null.
Parameters:
Name Type Description constraint_namestring The name of the constraint to create
parsefunctionstring The function local name
parsenamesapcestring The namespace of the function
parselibrarystring The XQuery library path in the modules database for the function
startfunctionstring The function local name
startnamesapcestring The namespace of the function
startlibrarystring The XQuery library path in the modules database for the function
finishfunctionstring The function local name
finishnamesapcestring The namespace of the function
finishlibrarystring The XQuery library path in the modules database for the function
annotation_optstring | Array The annotation to add to the constraint. MLJS uses annotation[0] as the display title, falling back to camel case constraint name if not specified
additional_properties_optjson Additional rest api properties to apply to this constraint. Copied after constraint constructed. E.g. fragmentScope.
-
debug(dbg)
-
Specified the debug level for the search
Parameters:
Name Type Description dbgstring Search API debug level to use
-
defaultCollation(col)
-
Specifies the default collation applies to all string constraints and sorts, if not specified on constraint definition
Parameters:
Name Type Description colstring The default collation URL spec to use
-
defaultLimit(num)
-
Sets the default limit for values and tuples lookups (co-occurence and lexicon value listing)
Parameters:
Name Type Description numpostitiveInteger The limit of the number of results to return
-
defaultNamespace(ns)
-
Specifies the default element namespace to use
Parameters:
Name Type Description nsstring Sets the default namespace value
-
defaultSortOrder(sort)
-
Specifies the default sort order
Parameters:
Name Type Description sortstring The default sort order. 'ascending' (default) or 'descending'.
-
defaultType(type)
-
Specifies the default constraint type
Parameters:
Name Type Description typestring Sets the default type (default is xs:string)
-
elemattrRangeConstraint(constraint_name, elment, namespace, attr, type_opt, collation_opt, facet_opt, facet_options_opt, annotation_opt)
-
Creates a new element attribute range constraint, and adds it to the search options object
Parameters:
Name Type Description constraint_namestring Constraint name to use.
elmentstring Element name to use
namespacestring Namespace to use.
attrstring Element attribute to use
type_optstring XML Schema type. E.g. "xs:string". Optional. If not specified, default type is used.
collation_optstring The optional string collation to used. If not specified, default collation is used (if of xs:string type)
facet_optboolean Whether to use this constraint as a facet
facet_options_optJSON The optional facet configuration JSON to use.
annotation_optstring | Array The annotation to add to the constraint. MLJS uses annotation[0] as the display title, falling back to camel case constraint name if not specified
-
elementConstraint(constraint_name, elementname, elementns, annotation_opt)
-
Restricts all search parameters to the specified element.
Parameters:
Name Type Description constraint_namestring The name of the constraint to create
elementnamestring The name of the element to match
elementnsstring The namespace of the element to match
annotation_optstring | Array The annotation to add to the constraint. MLJS uses annotation[0] as the display title, falling back to camel case constraint name if not specified
- Deprecated:
- See {@see #elementContainerConstraint} . http://docs.marklogic.com/guide/rest-dev/appendixa#id_62771
- Source:
-
elementContainerConstraint(constraint_name, elementname, elementns, annotation_opt)
-
Restricts all search parameters to the specified element.
Parameters:
Name Type Description constraint_namestring The name of the constraint to create
elementnamestring The name of the element to match
elementnsstring The namespace of the element to match
annotation_optstring | Array The annotation to add to the constraint. MLJS uses annotation[0] as the display title, falling back to camel case constraint name if not specified
-
empty()
-
Uses empty snippet document snippeting mode.
-
extractAttributeMetadata(elementname, elementns, attributename, attributens_opt)
-
Extracts metadata for a single element's attribrute.
Parameters:
Name Type Description elementnamestring Local name of the element to extract
elementnsstring Namespace of the element to extract
attributenamestring Local name of the attribute
attributens_optstring Optional namespace of the attribute to extract. Defaults if not specified to the element namespace
-
extractConstraintMetadata(constraint_name)
-
Extracts metadata for a single constraint
Parameters:
Name Type Description constraint_namestring The name of the constraint whose content should be extracted
-
extractElementMetadata(elementname, elementns)
-
Extracts metadata for a single element.
Parameters:
Name Type Description elementnamestring Local name of the element to extract
elementnsstring Namespace of the element to extract
-
extractJsonMetadata(strings)
-
Extracts metadata from a json key value.
Parameters:
Name Type Description stringsstring | Array Single string or string array containing json key names
-
fieldRangeConstraint(constraint_name, name, type_opt, collation_opt, facet_opt, facet_options_opt, fragmentScope_opt, annotation_opt)
-
Specifies a new field range constraint, and adds it to the search options object
Parameters:
Name Type Description constraint_namestring Constraint name to use
namestring Field name to use
type_optstring xs:string or similar
collation_optstring The optional string collation to used. If not specified, default collation is used
facet_optboolean Use this constraint as a facet.
facet_options_optJSON The optional facet configuration JSON to use.
fragmentScope_optstring The fragment to use (defaults to document)
annotation_optstring | Array The annotation to add to the constraint. MLJS uses annotation[0] as the display title, falling back to camel case constraint name if not specified
-
forest(forests)
-
Specified the forest to search within
Parameters:
Name Type Description forestspositiveInteger | Array Which forest(s) to use. (Note: MarkLogic internal IDs can overload JavaScript's numeric types so must be used with caution.)
-
fragmentScope(scope)
-
Specified the fragment scope
Parameters:
Name Type Description scopestring Function scope to use
-
geoAttributePairConstraint(constraint_name, parentelement, parentns, latattr, latns, lonattr, lonns, heatmap_opt, geo_options_opt, facet_opt, facet_options_opt, annotation_opt, additional_properties_opt)
-
Specifies a geospatial element attribute pair constraint, and adds it to the search options object
http://docs.marklogic.com/guide/rest-dev/appendixa#id_41124 NB Requires WGS84 or RAW co-ordinates (depending on how you are storing your data) - See the proj4js project for conversions
Parameters:
Name Type Description constraint_namestring Name of the constraint to create
parentelementstring Parent element name
parentnsstring Optional namespace of the parent element. If not provided, uses the default namespace
latattrstring Attribute name of the latitude attribute within the parent
latnsstring Namespace of the latitude element within the parent
lonattrstring Attribute name of the longitude Attribute within the parent
lonnsstring Namespace of the longitude element within the parent
heatmap_optjson Optional heatmap json configuration
geo_options_optArray Optional array of strings to use as options for this geo constraint
facet_optboolean Whether to include this constraint as a facet
facet_options_optjson Options for the facet based on this constraint
annotation_optstring | Array The annotation to add to the constraint. MLJS uses annotation[0] as the display title, falling back to camel case constraint name if not specified
additional_properties_optjson Additional rest api properties to apply to this constraint. Copied after constraint constructed. E.g. fragmentScope.
-
geoElementConstraint(constraint_name, parent, ns_opt, element, ns_el_opt, annotation_opt, additional_properties_opt)
-
Create a geospatial element pair constraint, and adds it to the search options object
Parameters:
Name Type Description constraint_namestring Name of the constraint to create
parentstring Parent element name
ns_optstring Optional namespace of the parent element. If not provided, uses the default namespace
elementstring Element name of the geospatial pair element
ns_el_optstring Optional namespace of the child geospatial element. If not configured will use the default namespace
annotation_optstring | Array The annotation to add to the constraint. MLJS uses annotation[0] as the display title, falling back to camel case constraint name if not specified
additional_properties_optjson Additional rest api properties to apply to this constraint. Copied after constraint constructed. E.g. fragmentScope.
-
geoElementPairConstraint(constraint_name, parentelement, parentns, latelement, latns, lonelement, lonns, heatmap_opt, geo_options_opt, facet_opt, facet_options_opt, annotation_opt, additional_properties_opt)
-
Creates an element pair geo constraint.
http://docs.marklogic.com/guide/rest-dev/appendixa#id_33146 NB Requires WGS84 or RAW co-ordinates (depending on how you are storing your data) - See the proj4js project for conversions
Parameters:
Name Type Description constraint_namestring Name of the constraint to create
parentelementstring Parent element name
parentnsstring Optional namespace of the parent element. If not provided, uses the default namespace
latelementstring Element name of the latitude element within the parent
latnsstring Namespace of the latitude element within the parent
lonelementstring Element name of the longitude element within the parent
lonnsstring Namespace of the longitude element within the parent
heatmap_optjson Optional heatmap json configuration
geo_options_optArray Optional array of strings to use as options for this geo constraint
facet_optboolean Whether to include this constraint as a facet
facet_options_optjson Options for the facet based on this constraint
annotation_optstring | Array The annotation to add to the constraint. MLJS uses annotation[0] as the display title, falling back to camel case constraint name if not specified
additional_properties_optjson Additional rest api properties to apply to this constraint. Copied after constraint constructed. E.g. fragmentScope.
-
geoPathConstraint(constraint_name, path, namespace_json, annotation_opt, additional_properties_opt)
-
Creates a geospatial path range index constraint.
Assumes the value of the element is "lat,lon". This can be reversed using the "long-lat-point" option. See the below URL for details.
http://docs.marklogic.com/guide/rest-dev/appendixa#id_86685 NB Requires WGS84 or RAW co-ordinates (depending on how you are storing your data) - See the proj4js project for conversions
NOTE: Any namespaces used in the XPath must be specified as {a: "myns1", b: "myns2"} in namespace_json
Parameters:
Name Type Description constraint_namestring Name of the constraint to create
pathstring The XPath of the element containing the coordinates.
namespace_jsonjson The namespace json to use. null if no namespaces are used in the path
annotation_optstring | Array The annotation to add to the constraint. MLJS uses annotation[0] as the display title, falling back to camel case constraint name if not specified
additional_properties_optjson Additional rest api properties to apply to this constraint. Copied after constraint constructed. E.g. fragmentScope.
-
getConstraint(name)
-
Returns a constraint definition based on constraint name.
Parameters:
Name Type Description namestring Constraint name for already defined constraint to return
-
getFacetValueString(facetname, facetvalue)
-
Returns the translated value for a given facet raw value.
Parameters:
Name Type Description facetnamestring The name of the facet (same as the constraint name by default)
facetvaluestring The raw facet value returned by MarkLogic
-
grouping(label, delimiter, strength, additional_properties)
-
Convenience method for defining a custom grammar starter. See starter() also.
Parameters:
Name Type Description labelstring the first encountered character to indicate this is a starter (E.g. '(' or '-' characters)
delimiterstring The trailing character to denote the end of this group. E.g. the ')' character. (Start character defined in 'label')
strengthinteger Precedence of this starter over others
additional_propertiesjson Other properties to add. E.g. element, delimiter, ns, at, tokenize
-
implicit(ctsquery)
-
The cts-query literal to use to join two terms together. See implicitAnd() and implicitOr() for convenience methods. Defaults to and-query.
Parameters:
Name Type Description ctsquerystring The serialized CTS query to use to join two terms together. See REST API docs for example.
-
implicitAnd()
-
Convenience function to specify an and-query as a term joiner for a custom grammar.
-
implicitOr()
-
Convenience function to specify an or-query as a term joiner for a custom grammar.
-
joiner(label, apply, strength, additional_properties)
-
Adds a joiner configuration to the custom search grammar definition.
Parameters:
Name Type Description labelstring The joiner word. E.g. "OR" or "AND"
applystring Local name of the function. E.g. "infix"
strengthinteger Precedence of this joiner over others
additional_propertiesjson Other properties to add. E.g. element, options, tokenize etc
-
jsonContainerConstraint(constraint_name, jsonkey, annotation_opt)
-
Restricts all search parameters to the specified json key.
Parameters:
Name Type Description constraint_namestring The name of the constraint to create
jsonkeystring The name of the json property (key) to match
annotation_optstring | Array The annotation to add to the constraint. MLJS uses annotation[0] as the display title, falling back to camel case constraint name if not specified
-
jsonRangeConstraint(name_or_key, type_opt, collation_opt, facet_opt, facet_options_opt, fragmentScope_opt, annotation_opt)
-
Convenience method to create a range constraint for a JSON key (uses the MarkLogic basic JSON namespace)
Parameters:
Name Type Description name_or_keystring JSON key to use
type_optstring Whether to use 'json' (default) or 'xml' element matching
collation_optstring The optional string collation to used. If not specified, default collation is used
facet_optboolean Include this constraint as a facet?
facet_options_optJSON The optional facet configuration JSON to use.
fragmentScope_optstring The fragment to use (defaults to document)
annotation_optstring | Array The annotation to add to the constraint. MLJS uses annotation[0] as the display title, falling back to camel case constraint name if not specified
-
metadata()
-
Uses metadata-snippet document snippeting mode.
-
noDLSVersions()
-
Sets additional query to one that ensures no DLS declared document versions are returned (except the latest version at the original URL).
-
pageLength(length)
-
Specifies the number of search results to return on each page
Parameters:
Name Type Description lengthpositiveInteger Page length to use. If not specified, uses the default (10).
-
pathConstraint(constraint_name, xpath, namespaces, type_opt, collation_opt, facet_opt, facet_options_opt, annotation_opt)
-
Generates a new Xpath constraint
Parameters:
Name Type Description constraint_namestring The name of the constraint
xpathstring The XPath path
namespacesjson The {prefix: "http://name/space/", ...} JSON listing namespaces to use
type_optstring The type of the XPath attribute/element pointed at. Defaults to xs:string. Must have xs: prefix.
collation_optstring The collation to use (if an xs:string), defaults to the value of defaultCollation in this options builder instance
facet_optboolean Whether to use this in a facet. Defaults to true. NB CURRENTLY THE REST API DOES NOT SUPPORT XPATH FACETS
facet_options_optArray Additional string array XPath options - See http://docs.marklogic.com/guide/rest-dev/appendixa#id_64714
annotation_optstring | Array The annotation to add to the constraint. MLJS uses annotation[0] as the display title, falling back to camel case constraint name if not specified
-
prefix(label, element, strength, additional_properties)
-
Convenience method for defining a custom grammar starter. See starter() also.
Parameters:
Name Type Description labelstring the first encountered character to indicate this is a starter (E.g. '(' or '-' characters)
elementstring Query to use. E.g. "cts:not-query"
strengthinteger Precedence of this starter over others
additional_propertiesjson Other properties to add. E.g. element, delimiter, ns, at, tokenize
-
propertiesConstraint(constraint_name_opt)
-
Adds a properties constraint to the search options. Forces the entire search to be constrained to the properties fragment only.
Parameters:
Name Type Description constraint_name_optstring Optional name of the constraint to create
-
qualityWeight(weight)
-
Specified the quality weight
Parameters:
Name Type Description weightdouble Default search weight to use.
-
quotation(quotation)
-
Specifies the quotation character for this custom grammar
Parameters:
Name Type Description quotationstring Quotation character. E.g. "\""
-
rangeConstraint(constraint_name_opt, name_or_key, ns_opt, type_opt, collation_opt, facet_opt, facet_options_opt, fragmentScope_opt, annotation_opt)
-
Specifies a new range constraint, and adds it to the search options object
Parameters:
Name Type Description constraint_name_optstring Optional constraint name to use. Defaults to NULL
name_or_keystring Element name or JSON key to use
ns_optstring Namespace to use. Optional. If not specified, default namespace is used. (If type is XML element)
type_optstring Whether to use 'json' (default) or 'xml' element matching
collation_optstring The optional string collation to used. If not specified, default collation is used
facet_optboolean Include this constraint as a facet?
facet_options_optJSON The optional facet configuration JSON to use.
fragmentScope_optstring The fragment to use (defaults to document)
annotation_optstring | Array The annotation to add to the constraint. MLJS uses annotation[0] as the display title, falling back to camel case constraint name if not specified
-
raw()
-
Uses RAW document snippeting mode.
-
returnAggregates(ret)
-
Specified whether to return aggregates
Parameters:
Name Type Description retboolean Whether to return aggregate values.
-
returnConstraints(ret)
-
Specified whether to return constraints
Parameters:
Name Type Description retboolean Whether to return query constraint settings in the response.
-
returnFacets(ret)
-
Specified whether to return facets
Parameters:
Name Type Description retboolean Whether to return facets
-
returnFrequencies(ret)
-
Specified whether to return frequencies
Parameters:
Name Type Description retboolean Whether to return Frequencies
-
returnMetrics(ret)
-
Specified whether to return search metrics
Parameters:
Name Type Description retboolean Whether to return search metrics.
-
returnPlan(ret)
-
Specifies whether to return the internal search plan generated by the search query (Useful to debug poorly performing queries)
Parameters:
Name Type Description retboolean Whether to return the internal search API plan. Useful to debug search performance issues.
-
returnQtext(ret)
-
Specifies whether to return the query text with the search results
Parameters:
Name Type Description retboolean Whether to returnthe query text with the response.
-
returnQuery(ret)
-
Specifies whether to return the entire query with the search results
Parameters:
Name Type Description retboolean Whether to return th query with the response.
-
returnResults(ret)
-
Specifies whether to return search result documents (or snippets thereof)
Parameters:
Name Type Description retboolean Whether to return search results. (Useful if you're just doing a values() co-occurence or lexicon lookup)
-
returnSimilar(ret)
-
Specifies whether to return cts:similar documents to those in the search results
Parameters:
Name Type Description retboolean Whether to return cts:similar documents for each search match.
-
returnValues(ret)
-
Specifies whether to return values objects
Parameters:
Name Type Description retboolean Whether to return values (co-occurence) matches with the response. (applies to /v1/values calls only)
-
searchableExpression(path, namespace_json)
-
Restricts the query to the specified XPath searchable expression.
http://docs.marklogic.com/guide/rest-dev/appendixa#id_65046
NOTE: Any namespaces used in the XPath must be specified as {a: "myns1", b: "myns2"} in namespace_json
Parameters:
Name Type Description pathstring The XPath of the element to restrict search constraints to.
namespace_jsonjson The namespace json to use. null if no namespaces are used in the path
-
searchableExpression(expression, namespaces_opt)
-
Restricts results (e.g. for snippeting) to those elements within the given XPath expression. Facets still operate at the document level even if they are not within the searchable expression.
http://docs-ea.marklogic.com/guide/rest-dev/appendixa#id_65046
Parameters:
Name Type Description expressionstring The XPath expression to return in the search results (E.g. for snippeting)
namespaces_optstring A JSON object of {prefix: "namespace/string", ...} specifying namespaces used within the XPath (if any)
-
searchOptions(searchOptions)
-
Specifies the search options to configure. E.g. filtered, unfiltered, score-logtfidf.
Parameters:
Name Type Description searchOptionsstring | Array A single string option, or string array, holding search options.
-
setFacetValueStrings(facetname, valuehash)
-
Sets the matrix of facet values. Useful to translate codes on the fly to human readable values in facets. This lives in the options object as a convenience for objects to populate strings and retrieve displayable values. This is NOT a feature of the core REST API exposed in the Options object, but a convenience built over them.
Parameters:
Name Type Description facetnamestring The name of the facet (same as the constraint name by default) these values apply to
valuehashjson A JSON object with raw facet values as keys, and translated (for display) values as values - { "SOME/value": "Some value", ... }
-
snippet(ns_opt, at_opt, additional_opt)
-
Uses default snippeting document snippeting mode.
NB To configure default snippeting function use snippet(null,null,{"max-matches": 10}) or similar
Parameters:
Name Type Description ns_optstring The optional XQuery namespace of the snippeting module to invoke
at_optstring The relative location in the REST modules database to find the snippeting module to invoke
additional_optjson Map containing additional properties. E.g. "preferred-elements" or "max-matches"
-
sortOrder(direction_opt, type_opt, keyOrJSON, collation_opt)
-
Specifies the sort order. Automatically called for any of the range constraint constructor functions.
Parameters:
Name Type Description direction_optstring The direction (ascending or descending) to use. If not specified, uses the default direction.
type_optstring The type of the sort element. If not specified uses the default type.
keyOrJSONstring | JSON The JSON key or XML index JSON description to use. {element: "year", elementns: "http://...", attribute: "gregorian", attributens: "http://" OR FOR FIELD: field: "myfield", collation: "http://..." OR JSON key: "key" - All support annotation: "" | ["","",...] }
collation_optstring The optional collation to use. Uses the default collation if not specified.
-
sortOrderClear()
-
Clears any default or specified sort order definitions
-
sortOrderScore()
-
Specifies score as the sort order
-
starter(label, apply, strength, additional_properties)
-
Defines a Custom Grammar starter. This enables term grouping (E.g. ( and ) is a group) and prefixing (E.g. negation). See also the convenience grouping() and prefix() methods.
Parameters:
Name Type Description labelstring the first encountered character to indicate this is a starter (E.g. '(' or '-' characters)
applystring Whether this should be a "grouping" or "prefix" starter
strengthinteger Precedence of this starter over others
additional_propertiesjson Other properties to add. E.g. element, delimiter, ns, at, tokenize
-
thesaurusConstraint(constraint_name, additional_properties_opt)
-
Adds a thesaurus constraint to these options. Uses a custom constraint. NOTE: You MUST alter the custom constraint to specify your own thesaurus xml file. This should be only as large as your application requires.
https://github.com/adamfowleruk/mljs/tree/master/mldbwebtest/src/app/models/lib-thesaurus.xqy
Parameters:
Name Type Description constraint_namestring The name of the constraint to create
additional_properties_optjson Additional rest api properties to apply to this constraint. Copied after constraint constructed. E.g. fragmentScope.
-
toJson()
-
Returns the JSON search options object needed by the REST API and generated by this class
-
transformResults(apply, ns_opt, at_opt)
-
Specifies the results transformation options. Defaults to raw (full document returned).
Parameters:
Name Type Description applystring The XQuery function name
ns_optstring The optional XQuery namespace of the module to invoke
at_optstring The relative location in the REST modules database to find the transform to invoke
-
tuples(name, el)
-
Creates a tuples definition for returning co-occurence values
Parameters:
Name Type Description namestring The name of the tuples configuration to create
elstring | JSON The json element for a co-occurence. Either a range constraint name, element/json key name (string) or a full REST API range type object (JSON). You can specify any number of these as required (minimum 2)
-
valueConstraint(constraint_name_opt, name_or_key, ns_opt, fragmentScope_opt, annotation_opt)
-
Creates a new value Constraint, and adds it to the search options object
MarkLogic does not support faceting or sorting for value constraints - add a range constraint and range index for this functionality.
Parameters:
Name Type Description constraint_name_optstring Optional constraint name to use. Defaults to NULL
name_or_keystring Element name or JSON key to use
ns_optstring Namespace to use. Optional. If not specified, default namespace is used. (If type is XML element)
fragmentScope_optstring The fragment to use (defaults to document)
annotation_optstring | Array The annotation to add to the constraint. MLJS uses annotation[0] as the display title, falling back to camel case constraint name if not specified
-
values(name, el)
-
Creates a values definition for returning lexicon values
Parameters:
Name Type Description namestring The name of the values configuration to create
elstring | JSON The json element for a co-occurence. Either a range constraint name, element/json key name (string) or a full REST API range type object (JSON). You can specify any number of these as required