Constructor
new NumericFilter()
- Source:
Extends
Members
type :string
The name of this Model
Type:
- Overrides:
- Source:
Methods
coordDefaults(coord) → {Object}
For filters that represent geographic coordinates, return the
appropriate defaults for the NumericFilter model.
Parameters:
Name |
Type |
Description |
coord |
'latitude'
|
'longitude'
|
The coordinate type to get
defaults for. |
- Source:
Returns:
The rangeMin, rangeMax, and step values for the
given coordinate type
-
Type
-
Object
defaults()
Default attributes for this model
Properties:
Name |
Type |
Description |
min |
Date
|
The minimum number to use in the query for this filter |
max |
Date
|
The maximum number to use in the query for this filter |
rangeMin |
Date
|
The lowest possible number that 'min' can be |
rangeMax |
Date
|
The highest possible number that 'max' can be |
nodeName |
string
|
The XML node name to use when serializing this model into XML |
range |
boolean
|
If true, this Filter will use a numeric range as the search term instead of an exact number |
step |
number
|
The number to increase the search value by when incrementally increasing or decreasing the numeric range |
- Overrides:
- Source:
escapeSpecialChar(term) → {string}
Escapes Solr query reserved characters so that search terms can include
those characters without throwing an error.
Parameters:
Name |
Type |
Description |
term |
string
|
The search term or phrase to escape |
- Inherited From:
- Source:
Returns:
- The search term or phrase, after special characters are escaped
-
Type
-
string
getQuery() → {string}
Builds a query string that represents this filter.
- Overrides:
- Source:
Returns:
The query string to send to Solr
-
Type
-
string
getReadableValue() → {string}
Creates a human-readable string that represents the value set on this model
- Source:
Returns:
-
Type
-
string
getValueQuerySubstring(valuesopt) → {string}
Constructs a query substring for each of the values set on this model
Parameters:
Name |
Type |
Attributes |
Description |
values |
Array.<string>
|
<optional>
|
The values to use in this query substring.
If not provided, the values set on the model are used. |
- Inherited From:
- Source:
Returns:
The query substring
-
Type
-
string
Example
values: ["walker", "jones"]
Returns: "(walker%20OR%20jones)"
hasChangedValues() → {boolean}
Checks if this Filter has values different than the default values.
- Overrides:
- Source:
Returns:
- Returns true if this Filter has values set on it, otherwise will return false
-
Type
-
boolean
initialize()
Creates a new Filter model
- Overrides:
- Source:
isCoordinateQuery(fieldsopt) → {Boolean}
Check whether a set of query fields contain only fields that specify latitude and/or
longitude
Parameters:
Name |
Type |
Attributes |
Description |
fields |
Array.<string>
|
<optional>
|
A list of fields to check for coordinate fields. If not
provided, the fields set on the model will be used. |
- Since:
- Inherited From:
- Source:
Returns:
Returns true if every field is a field that specifies latitude or
longitude
-
Type
-
Boolean
isDateQuery(value) → {boolean}
Returns true if the given value or value set on this filter is a date range query
Parameters:
Name |
Type |
Description |
value |
string
|
The string to test |
- Inherited From:
- Source:
Returns:
-
Type
-
boolean
isEmpty() → {boolean}
isEmpty - Checks whether this Filter has any values or fields set
- Inherited From:
- Source:
Returns:
returns true if the Filter's values and fields are empty
-
Type
-
boolean
isIdFilter()
- Since:
- Inherited From:
- Source:
isLatitudeQuery(fieldsopt) → {Boolean}
Check whether a set of query fields contain only fields that specify latitude
Parameters:
Name |
Type |
Attributes |
Description |
fields |
Array.<string>
|
<optional>
|
A list of fields to check for coordinate fields. If not
provided, the fields set on the model will be used. |
- Since:
- Inherited From:
- Source:
Returns:
Returns true if every field is a field that specifies latitude
-
Type
-
Boolean
isLongitudeQuery(fieldsopt) → {Boolean}
Check whether a set of query fields contain only fields that specify longitude
Parameters:
Name |
Type |
Attributes |
Description |
fields |
Array.<string>
|
<optional>
|
A list of fields to check for longitude fields. If not
provided, the fields set on the model will be used. |
- Since:
- Inherited From:
- Source:
Returns:
Returns true if every field is a field that specifies longitude
-
Type
-
Boolean
limitToRange()
Ensures that the min, max, and value are within the rangeMin and rangeMax.
- Source:
parse(xml) → {JSON}
Parses the numericFilter XML node into JSON
Parameters:
Name |
Type |
Description |
xml |
Element
|
The XML Element that contains all the NumericFilter elements |
- Overrides:
- Source:
Returns:
- The JSON object literal to be set on the model
-
Type
-
JSON
parseFilterOptions(filterOptionsNode) → {Object}
Parses the filterOptions XML node into a literal object
Parameters:
Name |
Type |
Description |
filterOptionsNode |
Element
|
The filterOptions XML element to parse |
- Inherited From:
- Source:
Returns:
- The parsed filter options, in literal object form
-
Type
-
Object
parseTextNode(parentNode, nodeName, isMultiple) → {string|Array}
Gets the text content of the XML node matching the given node name
Parameters:
Name |
Type |
Description |
parentNode |
Element
|
The parent node to select from |
nodeName |
string
|
The name of the XML node to parse |
isMultiple |
boolean
|
If true, parses the nodes into an array |
- Inherited From:
- Source:
Returns:
- Returns a string or array of strings of the text content
-
Type
-
string
|
Array
requiresPositiveClause(groupLevelOperatoropt) → {boolean}
For "negative" Filters (filter models where exclude is set to true), detects
whether the query requires an additional "positive" query phrase in order to avoid
the problem of pure negative queries returning zero results. If this Filter is not
part of a collection of Filters, assume it needs the positive clause. If this
Filter is part of a collection of Filters, detect whether there are other,
"positive" filters in the same query (i.e. filter models where exclude is set to
false). If there are other positive queries, then an additional clause is not
required. If the Filter is part of a pure negative query, but it is not the last
filter, then don't add a clause since it will be added to the last, and only one
is required. When looking for other positive and negative filters, exclude empty
filters and filters that use any of the identifier fields, as these are appended to
the end of the query.
Parameters:
Name |
Type |
Attributes |
Description |
groupLevelOperator |
string
|
<optional>
|
"AND" or "OR". The operator used in the
parent Filters collection to combine the filter query fragments together. If the
group level operator is "OR" and this filter has exclude set to TRUE, then a
positive clause is required. |
- Inherited From:
- Source:
- See:
-
Returns:
returns true of this Filter needs a positive clause, false
otherwise
-
Type
-
boolean
resetValue()
Resets the values attribute on this filter
- Inherited From:
- Source:
roundToStep()
Rounds the min, max, and/or value to the same number of decimal
places as the step.
- Source:
toggleCoordinateLimits(overwriteopt)
Add or remove the rangeMin, rangeMax, and step associated with
coordinate queries. If the filter is a coordinate filter, then add
the appropriate defaults for the rangeMin, rangeMax, and step. If
the filter is NOT a coordinate filter, then set rangeMin, rangeMax,
and step to the regular defaults for a numeric filter.
Parameters:
Name |
Type |
Attributes |
Default |
Description |
overwrite |
Boolean
|
<optional>
|
false
|
By default, the rangeMin,
rangeMax, and step will only be reset if they are currently set to
one of the default values (e.g. if the model has default values for
a numeric filter, they will be set to the default values for a
coordinate filter). To change this behaviour to always reset the
attributes to the new defaults values, set overwrite to true. |
- Source:
updateDOM(optionsopt) → {Element}
Updates XML DOM with the new values from the model
Parameters:
Name |
Type |
Attributes |
Description |
options |
object
|
<optional>
|
A literal object with options for this serialization |
- Overrides:
- Source:
Returns:
A new XML element with the updated values
-
Type
-
Element
updateFilterOptionsDOM(filterOptionsNodeopt) → {Element}
Serializes the filter options into an XML DOM and returns it
Parameters:
Name |
Type |
Attributes |
Description |
filterOptionsNode |
Element
|
<optional>
|
The XML filterOptions node to update |
- Inherited From:
- Source:
Returns:
- The updated DOM
-
Type
-
Element
validate() → {object}
Checks if the values set on this model are valid and expected
- Overrides:
- Source:
Returns:
- Returns a literal object with the invalid attributes and their corresponding error message
-
Type
-
object