Class: query

mljs# query

new query()

Creates a structured query builder object

Deprecated:
  • Call var db = new mljs(); var qb = db.createQuery(); instead
    Source:

    Methods

    and(query)

    Creates an and query, and returns it

    Parameters:
    Name Type Description
    query JSON

    The query, or array of queries, to use within the constructed and query

    Source:

    collection(uri_opt, depth_opt)

    Creates a collection query, and returns it

    Parameters:
    Name Type Description
    uri_opt string

    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_opt integer

    What depth in the child collections to include (defaults to infinite if not specified)

    Source:

    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_name string

    The name of the constraint configured in the search options for this container.

    query JSON

    The query, or array of queries, to use within the constructed or query

    Source:

    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
    query JSON

    The query JSON object. E.g. returned by geoElementPair(...)

    Source:
    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_name string

    The name of the constraint configured in the search options for this element.

    query JSON

    The query, or array of queries, to use within the constructed or query

    Source:

    elementValue(elementname, elementns, value)

    Creates an element value query. http://docs.marklogic.com/guide/search-dev/structured-query#id_39758

    Parameters:
    Name Type Description
    elementname string

    The name of the element

    elementns string

    The namespace of the element

    value string

    The value of the element

    Source:

    geoBox(constraint_name, north, east, wouth, west)

    Creates a geospatial bounding box query and returns it

    Parameters:
    Name Type Description
    constraint_name string

    Name of the matching constraint to restrict by these values

    north integer

    WGS84 north latitude

    east integer

    WGS84 east longitude

    wouth integer

    WGS84 wouth latitude

    west integer

    WGS84 west longitude

    Source:

    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
    parentelement string

    parent element name. E.g. or location: {lat:...,lon:...}

    parentns string

    parent namespace (provide null if none, or "http://marklogic.com/xdmp/json/basic" if JSON)

    latelement string

    latitude element. E.g. <lat> or lat: 51.1234

    latns string

    latitude namespace (provide null if none, or "http://marklogic.com/xdmp/json/basic" if JSON)

    lonelement string

    longitude element. E.g. <lon> or lat: 0.1234

    lonns string

    longitude namespace (provide null if none, or "http://marklogic.com/xdmp/json/basic" if JSON)

    pointlat float

    longitude in WGS84 or RAW

    pointlon float

    longitude in WGS84 or RAW

    scoring_method_opt string

    Optional scoring method. Defaults zero (others in V7: "reciprocal" (nearest first) or "linear" (furthest first)). NB Just ignored on V6.

    Source:

    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
    parentelement string

    parent element name. E.g. or location: {lat:...,lon:...}

    parentns string

    parent namespace (provide null if none, or "http://marklogic.com/xdmp/json/basic" if JSON)

    latelement string

    latitude element. E.g. >lat< or lat: 51.1234

    latns string

    latitude namespace (provide null if none, or "http://marklogic.com/xdmp/json/basic" if JSON)

    lonelement string

    longitude element. E.g. >lon< or lat: 0.1234

    lonns string

    longitude namespace (provide null if none, or "http://marklogic.com/xdmp/json/basic" if JSON)

    pointlat float

    longitude in WGS84 or RAW

    pointlon float

    longitude in WGS84 or RAW

    radius double

    Radius

    radius_unit double

    Unit to use. Supports "miles", "m" (metres), "km", "nm" (nautical miles), "degrees" (degrees longitude at the equator, or latitude)

    scoring_method_opt string

    Optional scoring method. Defaults zero (others in V7: "reciprocal" (nearest first) or "linear" (furthest first)). NB Just ignored on V6.

    Source:

    geoPolygon(constraint_name, points)

    Creates a geospatial polygon query and returns it

    Parameters:
    Name Type Description
    constraint_name string

    Name of the matching constraint to restrict by these values

    points Array

    Array of WGS 84 Points {latitude: , longitude: } JSON objects

    Source:

    geoRadius(constraint_name, lat, lon, radius, radiusmeasure_opt)

    Creates a geospatial circle query and returns it

    Parameters:
    Name Type Description
    constraint_name string

    Name of the matching constraint to restrict by these values

    lat integer

    WGS84 latitude

    lon integer

    WGS84 Longitude

    radius positiveInteger

    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_opt string

    The units used. Default is mi=statute miles. Also m=metres, km=kilometres, nm=nautical miles, degrees=degrees of rotation of the Earth

    Source:

    not(query)

    Creates a not query, and returns it

    Parameters:
    Name Type Description
    query JSON

    The query, or array of queries, to use within the constructed not query

    Source:

    or(query)

    Creates an or query, and returns it

    Parameters:
    Name Type Description
    query JSON

    The query, or array of queries, to use within the constructed or query

    Source:

    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_opt JSON

    The query to copy child values of to this query

    Source:

    range(constraint_name, val, range_operator_opt, options_opt)

    Creates a range constraint query and returns it

    Parameters:
    Name Type Description
    constraint_name string

    The constraint name from the search options for this constraint

    val string

    The value that matching documents must match

    range_operator_opt string

    The Optional operator to use. Default to EQ (=) if not provided. Valid values: LT, LE, GT, GE, EQ, NE

    options_opt Array

    The Optional String array options for the range index. E.g. ["score-function=linear","slope-factor=10"]

    Source:

    term(wordOrPhrase)

    Term (Word or phrase, anywhere in a document) query

    Parameters:
    Name Type Description
    wordOrPhrase string

    The word of phrase for the term query

    Source:

    toJson()

    Returns the JSON object used in the REST API (and mljs functions) that this query builder represents

    Source:

    uris(constraint_name, uris)

    Creates a document (uri list) query

    Parameters:
    Name Type Description
    constraint_name string

    The constraint name from the search options for this constraint

    uris string

    URI array for the documents to restrict search results to

    Source:

    value(constraint_name, val)

    Creates a value constraint query and returns it

    Parameters:
    Name Type Description
    constraint_name string

    The constraint name from the search options for this constraint

    val string

    THe value that matching documents must match

    Source:
    MLJS - A JavaScript wrapper for the MarkLogic REST API
    MarkLogic 2012-2014
    Documentation generated by JSDoc 3.2.3-dev on Mon Jul 18 2016 09:14:12 GMT+0100 (BST) using the DocStrap template.