Class: Filters

Filters()

A collection of Filter models that represents a full search

Constructor

new Filters()

Source:

Extends

  • Backbone.Collection

Members

mustMatchIds :boolean

If the search results must always match one of the ids in the id filters, then the id filters will be added to the query with an AND operator.
Type:
  • boolean
Source:

type :string

The name of this type of collection
Type:
  • string
Since:
  • 2.25.0
Default Value:
  • "Filters"
Source:

Methods

addOwnershipFilter()

Creates and adds a Filter to this collection that filters datasets to only those that the logged-in user has permission to change permission of.
Source:

addWritePermissionFilter()

Creates and adds a Filter to this collection that filters datasets to only those that the logged-in user has permission to write to.
Source:

createCatalogSearchQuery() → {string}

Create a partial query string that's required for catalog searches
Source:
Returns:
- Returns the query string fragment for a catalog search
Type
string

filterIsAvailable()

Given a Solr field name, determines if that field is set as a filter option
Source:

getAllOfType(type) → {Array.<Filter>}

Get all filters in this collection that are of a given filter type.
Parameters:
Name Type Description
type string The filter type to get, e.g. "BooleanFilter". If not set, all filters will be returned.
Source:
Returns:
An array of filter models
Type
Array.<Filter>

getGeohashLevels() → {Array.<string>}

Returns the geohash levels that are set on any SpatialFilter models in this collection. If no SpatialFilter models are found, or no geohash levels are set, an empty array is returned.
Source:
Returns:
An array of geohash levels in the format ["geohash_1", "geohash_2", ...]
Type
Array.<string>

getGroupQuery(filterModels, operatoropt) → {string}

Get a query string for a group of Filters. The Filters will be ANDed together, unless a different operator is given.
Parameters:
Name Type Attributes Default Description
filterModels Filter | BooleanFilter | ChoiceFilter | DateFilter | NumericFilter | ToggleFilter | Array.<FilterGroup> The Filters to turn into a query string
operator string <optional>
"AND" The operator to use between filter models
Source:
Returns:
The query string
Type
string

getIdFilters() → {Filter|BooleanFilter|ChoiceFilter|DateFilter|NumericFilter|ToggleFilter|Array.<FilterGroup>}

Searches the Filter models in this collection and returns any that have at least one field that matches any of the ID query fields, such as by id, seriesId, or the isPartOf relationship.
Source:
Returns:
Returns an array of filter models that include at least one ID field
Type
Filter | BooleanFilter | ChoiceFilter | DateFilter | NumericFilter | ToggleFilter | Array.<FilterGroup>

getNonEmptyFilters() → {Filter|BooleanFilter|ChoiceFilter|DateFilter|NumericFilter|ToggleFilter|Array.<FilterGroup>}

getNonEmptyFilters - Returns the array of filters that are not empty
Source:
Returns:
returns an array of Filter or FilterGroup models that are not empty
Type
Filter | BooleanFilter | ChoiceFilter | DateFilter | NumericFilter | ToggleFilter | Array.<FilterGroup>

getNonIdFilters() → {Filter|BooleanFilter|ChoiceFilter|DateFilter|NumericFilter|ToggleFilter|Array.<FilterGroup>}

Searches the Filter models in this collection and returns all have no fields matching any of the ID query fields.
Source:
Returns:
Returns an array of filter models that do not include any ID fields
Type
Filter | BooleanFilter | ChoiceFilter | DateFilter | NumericFilter | ToggleFilter | Array.<FilterGroup>

getQuery(operatoropt) → {string}

Builds the query string to send to the query engine. Iterates over each filter in the collection and adds to the query string.
Parameters:
Name Type Attributes Default Description
operator string <optional>
AND The operator to use to combine multiple filters in this filter group. Must be AND or OR.
Source:
Returns:
The query string to send to Solr
Type
string

initialize(models, optionsopt)

Function executed whenever a new Filters collection is created.
Parameters:
Name Type Attributes Description
models Filter | BooleanFilter | ChoiceFilter | DateFilter | NumericFilter | ToggleFilter | Array.<FilterGroup> Array of filter or filter group models to add to this creation
options Object <optional>
-
Properties:
Name Type Description
isUIFilterType boolean Set to true to indicate that these filters or filterGroups are part of a UIFilterGroup (aka custom Portal search filter). Otherwise, it's assumed that this model is in a Collection model definition.
objectDOM XMLElement A FilterGroupType or UIFilterGroupType XML element from a portal or collection document. If provided, the XML will be parsed and the Filters models extracted
catalogSearch boolean If set to true, a catalog search phrase will be appended to the search query that limits the results to un-obsoleted metadata.
Source:

model(attrs, options) → {Filter|BooleanFilter|ChoiceFilter|DateFilter|NumericFilter|ToggleFilter|FilterGroup}

Creates the type of Filter Model based on the given filter type. This function is typically not called directly. It is used by Backbone.js when adding a new model to the collection.
Parameters:
Name Type Description
attrs object A literal object that contains the attributes to pass to the model
options object A literal object of additional options to pass to the model
Properties:
Name Type Description
attrs.filterType string The type of Filter to create
attrs.objectDOM XMLElement The Filter XML
Source:
Returns:
Type
Filter | BooleanFilter | ChoiceFilter | DateFilter | NumericFilter | ToggleFilter | FilterGroup

parse(objectDOM, isUIFilterType) → {JSON}

Parses a or element from a collection or portal document and sets the resulting models on this collection.
Parameters:
Name Type Description
objectDOM XMLElement A FilterGroupType or UIFilterGroupType XML element from a portal or collection document
isUIFilterType boolean Set to true to indicate that these filters or filterGroups are part of a UIFilterGroup (aka custom Portal search filter). Otherwise, it's assumed that the filters are part of a Collection model definition.
Source:
Returns:
The result of the parsed XML, in JSON.
Type
JSON

removeEmptyFilters(recursiveopt)

Remove filters from the collection that are lacking fields, values, and in the case of a numeric filter, a min and max value.
Parameters:
Name Type Attributes Default Description
recursive boolean <optional>
false Set to true to also remove empty filters from within any and all nested filterGroups.
Source:

removeFiltersByField(field)

Removes Filter models from this collection if they match the given field
Parameters:
Name Type Description
field string The field whose matching filters that should be removed from this collection
Source:

replaceModel(model, newAttrs) → {Filter}

Remove a Filter from the Filters collection silently, and replace it with a new model.
Parameters:
Name Type Description
model Filter The model to replace
newAttrs object Attributes for the replacement model. Use the filterType attribute to replace with a different type of Filter.
Source:
Returns:
Returns the replacement Filter model, which is already part of the Filters collection.
Type
Filter

visibleIndexOf(model) → {number}

visibleIndexOf - Get the index of a given model, excluding any filters that are marked as invisible.
Parameters:
Name Type Description
model Filter | BooleanFilter | NumericFilter | DateFilter The filter model for which to get the visible index
Source:
Returns:
An integer representing the filter model's position in the list of visible filters.
Type
number