new query()
Creates a structured query builder object
Methods
-
and(query)
-
Creates an and query, and returns it
Parameters:
Name Type Description queryJSON The query, or array of queries, to use within the constructed and query
-
collection(uri_opt, depth_opt)
-
Creates a collection query, and returns it
Parameters:
Name Type Description uri_optstring The optional URI to use as the base. If not specified a blank '' value is used (i.e. all collections returned to the specified depth)
depth_optinteger What depth in the child collections to include (defaults to infinite if not specified)
-
container(constraint_name, query)
-
Creates an container (element or JSON key) constraint query, with optional query to be applied to the contents of that element.
Parameters:
Name Type Description constraint_namestring The name of the constraint configured in the search options for this container.
queryJSON The query, or array of queries, to use within the constructed or query
-
dynamic(query) → {function}
-
Allows a query term to be changed on the fly, by returning a wrapper function that can be called with a JSON vars object. See mldbwebtest's page-mljstest-openlayers.js sample file.
Parameters:
Name Type Description queryJSON The query JSON object. E.g. returned by geoElementPair(...)
Returns:
func - the dynamic function to call with a JSON vars object: E.g. for a geoElementPair wrapper: {latitude: -51.2334, longitude: 0.345454}
- Type
- function
-
element(constraint_name, query)
-
Creates an element constraint query, with optional query to be applied to the contents of that element.
Parameters:
Name Type Description constraint_namestring The name of the constraint configured in the search options for this element.
queryJSON The query, or array of queries, to use within the constructed or query
-
elementValue(elementname, elementns, value)
-
Creates an element value query. http://docs.marklogic.com/guide/search-dev/structured-query#id_39758
Parameters:
Name Type Description elementnamestring The name of the element
elementnsstring The namespace of the element
valuestring The value of the element
-
geoBox(constraint_name, north, east, wouth, west)
-
Creates a geospatial bounding box query and returns it
Parameters:
Name Type Description constraint_namestring Name of the matching constraint to restrict by these values
northinteger WGS84 north latitude
eastinteger WGS84 east longitude
wouthinteger WGS84 wouth latitude
westinteger WGS84 west longitude
-
geoElementPairPoint(parentelement, parentns, latelement, latns, lonelement, lonns, pointlat, pointlon, scoring_method_opt)
-
Creates a geo element pair query. Useful for dynamically calculating relevance using distance from a known point.
Parameters:
Name Type Description parentelementstring parent element name. E.g.
or location: {lat:...,lon:...} parentnsstring parent namespace (provide null if none, or "http://marklogic.com/xdmp/json/basic" if JSON)
latelementstring latitude element. E.g. <lat> or lat: 51.1234
latnsstring latitude namespace (provide null if none, or "http://marklogic.com/xdmp/json/basic" if JSON)
lonelementstring longitude element. E.g. <lon> or lat: 0.1234
lonnsstring longitude namespace (provide null if none, or "http://marklogic.com/xdmp/json/basic" if JSON)
pointlatfloat longitude in WGS84 or RAW
pointlonfloat longitude in WGS84 or RAW
scoring_method_optstring Optional scoring method. Defaults zero (others in V7: "reciprocal" (nearest first) or "linear" (furthest first)). NB Just ignored on V6.
-
geoElementPairRadius(parentelement, parentns, latelement, latns, lonelement, lonns, pointlat, pointlon, radius, radius_unit, scoring_method_opt)
-
Creates a geo element pair query. Useful for dynamically calculating relevance using distance from a known point.
Parameters:
Name Type Description parentelementstring parent element name. E.g.
or location: {lat:...,lon:...} parentnsstring parent namespace (provide null if none, or "http://marklogic.com/xdmp/json/basic" if JSON)
latelementstring latitude element. E.g. >lat< or lat: 51.1234
latnsstring latitude namespace (provide null if none, or "http://marklogic.com/xdmp/json/basic" if JSON)
lonelementstring longitude element. E.g. >lon< or lat: 0.1234
lonnsstring longitude namespace (provide null if none, or "http://marklogic.com/xdmp/json/basic" if JSON)
pointlatfloat longitude in WGS84 or RAW
pointlonfloat longitude in WGS84 or RAW
radiusdouble Radius
radius_unitdouble Unit to use. Supports "miles", "m" (metres), "km", "nm" (nautical miles), "degrees" (degrees longitude at the equator, or latitude)
scoring_method_optstring Optional scoring method. Defaults zero (others in V7: "reciprocal" (nearest first) or "linear" (furthest first)). NB Just ignored on V6.
-
geoPolygon(constraint_name, points)
-
Creates a geospatial polygon query and returns it
Parameters:
Name Type Description constraint_namestring Name of the matching constraint to restrict by these values
pointsArray Array of WGS 84 Points {latitude: , longitude: } JSON objects
-
geoRadius(constraint_name, lat, lon, radius, radiusmeasure_opt)
-
Creates a geospatial circle query and returns it
Parameters:
Name Type Description constraint_namestring Name of the matching constraint to restrict by these values
latinteger WGS84 latitude
loninteger WGS84 Longitude
radiuspositiveInteger The radius from the circle centre to use. Defaults to statute (not nautical) miles. Supports "miles", "m" (metres), "km", "nm" (nautical miles), "degrees" (degrees longitude at the equator, or latitude)
radiusmeasure_optstring The units used. Default is mi=statute miles. Also m=metres, km=kilometres, nm=nautical miles, degrees=degrees of rotation of the Earth
-
not(query)
-
Creates a not query, and returns it
Parameters:
Name Type Description queryJSON The query, or array of queries, to use within the constructed not query
-
or(query)
-
Creates an or query, and returns it
Parameters:
Name Type Description queryJSON The query, or array of queries, to use within the constructed or query
-
query(query_opt)
-
Copies an existing query options object in to this object (pass a JSON structure query, not an mljs.query object). Also used to set the top level query object (E.g. pass this function the result of query.and()). MUST be called at least once in order for the query to be set, prior to calling toJson(). Otherwise you'll always have a BLANK query!!!
Parameters:
Name Type Description query_optJSON The query to copy child values of to this query
-
range(constraint_name, val, range_operator_opt, options_opt)
-
Creates a range constraint query and returns it
Parameters:
Name Type Description constraint_namestring The constraint name from the search options for this constraint
valstring The value that matching documents must match
range_operator_optstring The Optional operator to use. Default to EQ (=) if not provided. Valid values: LT, LE, GT, GE, EQ, NE
options_optArray The Optional String array options for the range index. E.g. ["score-function=linear","slope-factor=10"]
-
term(wordOrPhrase)
-
Term (Word or phrase, anywhere in a document) query
Parameters:
Name Type Description wordOrPhrasestring The word of phrase for the term query
-
toJson()
-
Returns the JSON object used in the REST API (and mljs functions) that this query builder represents
-
uris(constraint_name, uris)
-
Creates a document (uri list) query
Parameters:
Name Type Description constraint_namestring The constraint name from the search options for this constraint
urisstring URI array for the documents to restrict search results to
-
value(constraint_name, val)
-
Creates a value constraint query and returns it
Parameters:
Name Type Description constraint_namestring The constraint name from the search options for this constraint
valstring THe value that matching documents must match