Factories

ItemFactory

class ItemFactory()

A factory class for item collections

ItemFactory.ItemFactoryOptions()
Arguments
  • url (string) – Custom URL for collection

  • customParameters (object) – Custom parameters object

ItemFactory.create(search, project, options)

Creates the item collection

Arguments
  • search (Model) – The search model (this.options.search)

  • project (Model) – The project (this.options.project)

  • options (ItemFactoryOptions) – Additional options

Returns

Collection – - The items collection

Examples:

var factory = Factories.Collections.Items;
var collection = factory.create(this.options.search, this.options.project, options);
ItemFactory.createFromParams(params, url)

Creates the item collection from a parameters object

Arguments
  • params (Object) – The parameters object

  • url (String) – Custom url, if required

Returns

Collection – - The items collection

Examples:

var factory = Factories.Collections.Items;
var collection = factory.createFromParams(this.getCollectionParams());

AggregationsFactory

class AggregationsFactory()

A factory class for item collections

AggregationsFactory.AggregationsFactoryOptions()
Arguments
  • search (Model) – The search model (this.options.search)

  • project (Model) – The project (this.options.project)

  • content (String) – If fetch is not overriden, specifies the outer aggregation field

  • limit (String) – If fetch is not overriden, specifies size of the aggregation

  • field (String) – If fetch is not overriden, specifies the inner aggregation field

  • aggregate_method (String) – If fetch is not overriden, specifies aggregation method

AggregationsFactory.create(type, options)

Creates the item collection

Arguments
  • type (string) – Collection type, used for caching so make it unique per widget

  • extensions (AggregationsFactoryOptions) – Functions and properties in this object will be attached to the created collection prototype

Returns

Collection – - The aggregations collection

Examples:

var factory = Factories.Collections.Aggregations;
var collection = factory.create('MyCollection', this.getCollectionParams());

FacetsFactory

class FacetsFactory()

A factory class for item collections

FacetsFactory.FacetsFactoryOptions()
Arguments
  • itemsCollection (Collection) – If passed, links the collection to the item collection updates

  • nof_facets (Number) – Limits the number of facet values per facet

  • facet_fields (Array.<string>) – Only fetch specific facet fields

  • url (string) – Custom URL passed from custom widgets

  • customParameters (object) – Custom parameters object

FacetsFactory.create(search, project, options)

Creates the facets collection

Arguments
  • search (Model) – The search model (this.options.search)

  • project (Model) – The project (this.options.project)

  • options (FacetsFactoryOptions) – Options

Returns

Collection – - The items collection

Examples:

var factory = Factories.Collections.Facets;
var collection = factory.create(this.options.search, this.options.project);

MockItemFactory

class MockItemFactory()

A factory class for mocked item collections

MockItemFactory.create(search, project, items=null)

Creates the mocked item collection, with preloaded data and detached from the backend

Arguments
  • search (Model) – The search model (this.options.search)

  • project (Model) – The project (this.options.project)

  • items (Array.<object>) – Items to preload the collection with

Returns

Collection – - The items collection

Examples:

var factory = Factories.Collections.MockItems;
var collection = factory.create(this.options.search, this.options.project, [{ title: 'Item title' }]);