classMLQueryBuilder
Source: browserify/
angular service for building structured queries
Designed for one-way compatibility with a subset of the official node-client-api query-builder; queries written to MLQueryBuilder (excluding deprecated methods) should work with the offical API, but not necessarily vice-versa.
Additionally includes extension methods (on MLQueryBuilder.ext), supporting various constraint queries, operator state query components, and combined queries.
Property
Methods
- .
ext. collectionConstraint(name, values) - .
ext. combined(query[, qtext][, options]) - .
ext. constraint(type) - .
ext. customConstraint(name, values) - .
ext. geospatialConstraint(name, . . . values) - .
ext. geospatialValues(. . . values) - .
ext. operatorState(name, stateName) - .
ext. rangeConstraint(name[, operator], values[, options]) - .
ext. valueConstraint(name, values) - .
ext. wordConstraint(name, values)
new MLQueryBuilder()
Property
staticext
Object
query builder extensions
Methods
static.ext.collectionConstraint(name, values) → Object
Builds a collection-constraint-query
Parameters
Name | Type | Optional | Description |
---|---|---|---|
name |
String |
|
constraint name |
values |
(String or Array of String) |
|
the values the constraint should equal (logical OR) |
- Returns
-
Object
collection-constraint-query
static.ext.combined(query[, qtext][, options]) → Object
Builds a combined query
Parameters
Name | Type | Optional | Description |
---|---|---|---|
query |
Object |
|
a structured query (from MLQueryBuilder#where) |
qtext |
String |
Yes |
a query text string, to be parsed server-side |
options |
Object |
Yes |
search options |
- Returns
-
Object
combined query
static.ext.constraint(type) → function()
constraint query function factory
Parameter
Name | Type | Optional | Description |
---|---|---|---|
type |
String |
|
constraint type ( |
- Returns
-
function()
a constraint query builder function, one of:
static.ext.customConstraint(name, values) → Object
Builds a custom-constraint-query
Parameters
Name | Type | Optional | Description |
---|---|---|---|
name |
String |
|
constraint name |
values |
(repeatable String, Array of String, or Array of Object) |
|
the values the constraint should equal (logical OR) |
- Returns
-
Object
custom-constraint-query
static.ext.geospatialConstraint(name, ...values) → Object
builds a geospatial-constraint-query
Parameters
Name | Type | Optional | Description |
---|---|---|---|
name |
String |
|
constraint name |
values |
Object |
|
the geospatial values to parse Value can be repeated. |
- Returns
-
Object
geospatial-constraint-query
static.ext.geospatialValues(...values) → Object
Helper method: builds an object of points
, boxes
, circles
, and polygons
, used by MLQueryBuilder.ext.geospatialConstraint, for
use with
MLQueryBuilder.ext.customConstraint
examples:
qb.ext.geospatialConstraint('name',
{ latitude: 1, longitude: 2 },
{ south: 1, west: 2, north: 3, east: 4 }
);
qb.ext.customConstraint('name', qb.ext.geospatialValues(
{ latitude: 1, longitude: 2 },
{ south: 1, west: 2, north: 3, east: 4 }
));
Parameter
Name | Type | Optional | Description |
---|---|---|---|
values |
Object |
|
the geospatial values to parse Value can be repeated. |
- Returns
-
Object
parsed geospatial values
static.ext.operatorState(name, stateName) → Object
Builds an operator-state
query component
Parameters
Name | Type | Optional | Description |
---|---|---|---|
name |
String |
|
operator name |
stateName |
String |
|
operator-state name |
- Returns
static.ext.rangeConstraint(name[, operator], values[, options]) → Object
Builds a range-constraint-query
Parameters
Name | Type | Optional | Description |
---|---|---|---|
name |
String |
|
constraint name |
operator |
String |
Yes |
operator for matching constraint to |
values |
(String or Array of String) |
|
the values the constraint should equal (logical OR) |
options |
(String or Array of String) |
Yes |
range options: http://docs.marklogic.com/guide/rest-dev/appendixa#id_84264 |
- Returns
-
Object
range-constraint-query
static.ext.valueConstraint(name, values) → Object
Builds a value-constraint-query
Parameters
Name | Type | Optional | Description |
---|---|---|---|
name |
String |
|
constraint name |
values |
(String, Number, Array of String, Array of Number, or null) |
|
the values the constraint should equal (logical OR) |
- Returns
-
Object
value-constraint-query
static.ext.wordConstraint(name, values) → Object
Builds a word-constraint-query
Parameters
Name | Type | Optional | Description |
---|---|---|---|
name |
String |
|
constraint name |
values |
(String or Array of String) |
|
the values the constraint should equal (logical OR) |
- Returns
-
Object
word-constraint-query
boost(matching, boosting) → Object
Builds a boost-query
Parameters
Name | Type | Optional | Description |
---|---|---|---|
matching |
Object |
|
matching query |
boosting |
Object |
|
boosting query |
- See also
- http://docs.marklogic.com/jsdoc/queryBuilder.html#boost
- Returns
-
Object
boost-query
collection()
- Deprecated
- See also
- MLQueryBuilder.ext.collectionConstraint
constraint()
- Deprecated
- See also
- MLQueryBuilder.ext.constraint
custom()
- Deprecated
- See also
- MLQueryBuilder.ext.customConstraint
directory(uris[, infinite]) → Object
Builds a directory-query
Parameters
Name | Type | Optional | Description |
---|---|---|---|
uris |
(repeatable String or Array of String) |
|
the directory URIs to query (logical OR) |
infinite |
Boolean |
Yes |
whether to query into all sub-directories (defaults to |
- See also
- http://docs.marklogic.com/jsdoc/queryBuilder.html#directory
- Returns
-
Object
directory-query
document(...uris) → Object
Builds a document-query
Parameter
Name | Type | Optional | Description |
---|---|---|---|
uris |
String |
|
document URIs to match Value can be repeated. |
- See also
- http://docs.marklogic.com/jsdoc/queryBuilder.html#document
- Returns
-
Object
document-query
documentFragment(query) → Object
Builds a document-fragment-query
Parameter
Name | Type | Optional | Description |
---|---|---|---|
query |
Object |
|
sub query to be constrained to document fragments |
- See also
- http://docs.marklogic.com/jsdoc/queryBuilder.html#documentFragment
- Returns
-
Object
document-fragment-query
locksFragment(query) → Object
Builds a locks-fragment-query
Parameter
Name | Type | Optional | Description |
---|---|---|---|
query |
Object |
|
sub query to be constrained to document locks |
- See also
- http://docs.marklogic.com/jsdoc/queryBuilder.html#locksFragment
- Returns
-
Object
locks-fragment-query
not(query) → Object
Builds a not-query
Parameter
Name | Type | Optional | Description |
---|---|---|---|
query |
Object |
|
sub query to be negated |
- See also
- http://docs.marklogic.com/jsdoc/queryBuilder.html#not
- Returns
-
Object
not-query
operator()
- Deprecated
- See also
- MLQueryBuilder.ext.operator
or(...queries) → Object
Builds an or-query
Parameter
Name | Type | Optional | Description |
---|---|---|---|
queries |
Object |
|
sub queries Value can be repeated. |
- See also
- http://docs.marklogic.com/jsdoc/queryBuilder.html#or
- Returns
-
Object
or-query
properties()
- Deprecated
propertiesFragment(query) → Object
Builds a properties-fragment-query
Parameter
Name | Type | Optional | Description |
---|---|---|---|
query |
Object |
|
sub query to be constrained to properties fragments |
- See also
- http://docs.marklogic.com/jsdoc/queryBuilder.html#propertiesFragment
- Returns
-
Object
properties-fragment-query
query()
- Deprecated
- See also
- MLQueryBuilder#where
range()
- Deprecated
- See also
- MLQueryBuilder.ext.rangeConstraint
term(...terms) → Object
Builds a term-query
Parameter
Name | Type | Optional | Description |
---|---|---|---|
terms |
String |
|
terms to match (logical OR) Value can be repeated. |
- See also
- http://docs.marklogic.com/jsdoc/queryBuilder.html#term
- Returns
-
Object
term-query
text()
- Deprecated
- See also
- MLQueryBuilder.ext.combined
where(...queries) → Object
Creates a structured query from a set of sub-queries
Parameter
Name | Type | Optional | Description |
---|---|---|---|
queries |
Object |
|
sub queries Value can be repeated. |
- See also
- http://docs.marklogic.com/jsdoc/queryBuilder.html#where
- Returns
-
Object
structured query