BaseSearchFactory

Base factory to build elastic search requests.

Namespace

IO\Services\ItemSearch\Factories

Constants
Type Name Value Description

string

SORTING_ORDER_ASC

'asc'

string

SORTING_ORDER_DESC

'desc'

string

INHERIT_AGGREGATIONS

'aggregations'

string

INHERIT_COLLAPSE

'collapse'

string

INHERIT_EXTENSIONS

'extensions'

string

INHERIT_FILTERS

'filters'

string

INHERIT_MUTATORS

'mutators'

string

INHERIT_PAGINATION

'pagination'

string

INHERIT_RESULT_FIELDS

'resultFields'

string

INHERIT_SORTING

'sorting'

Properties
Type Name Description

array

$aggregations

array

$mutators

array

$filters

array

$resultFields

array

$filterInstances

array

$extensions

string

$collapseField

MultipleSorting

$sorting

RandomScore

$randomScoreModifier

int

$page

int

$itemsPerPage

string

$pluginNamespace

Methods
public static inherit($searchBuilder, $inheritedProperties = []):BaseSearchFactory

Create a new factory instance based on properties of an existing factory.

Parameters

Type

Name

Description

BaseSearchFactory

$searchBuilder

The search factory to inherit properties from.

array

$inheritedProperties

List of properties to inherit or null to inherit all properties.

public withMutator($mutator):Factories

Add a mutator

Parameters

Type

Name

Description

MutatorInterface

$mutator

public createFilter($filterClass):TypeInterface

Add a filter. Will create a new instance of the filter class if not already created.

Parameters

Type

Name

Description

string

$filterClass

public withFilter($filter):Factories

Add a filter. Will override existing filter instances.

Parameters

Type

Name

Description

TypeInterface

$filter

public withResultFields($fields):BaseSearchFactory

Set fields to be contained in search result.

Parameters

Type

Name

Description

string | array

$fields

Reference to a json file to load fields from or a list of field names.

public getResultFields()
public withExtension($extensionClass, $extensionParams = []):Factories

Add an extension.

Parameters

Type

Name

Description

string

$extensionClass

Extension class to add.

array

$extensionParams

Additional parameters to pass to extensions constructor

public getExtensions():array

Get all registered extensions

public withAggregation($aggregation):Factories

Add an aggregation

Parameters

Type

Name

Description

AggregationInterface

$aggregation

public setPage($page, $itemsPerPage):Factories

Set pagination parameters.

Parameters

Type

Name

Description

int

$page

int

$itemsPerPage

public sortBy($field, $order = self::SORTING_ORDER_DESC):Factories

Add sorting parameters

Parameters

Type

Name

Description

string

$field

The field to order by

string

$order

Direction to order results. Possible values: 'asc' or 'desc'

public sortByMultiple($sortingList):Factories

Add multiple sorting parameters

Parameters

Type

Name

Description

array

$sortingList

List of sorting parameters. Each entry should have a 'field' and an 'order' property.

public setOrder($idList)
Parameters

Type

Name

Description

``

$idList

public groupBy($field):Factories

Group results by field

Parameters

Type

Name

Description

string

$field

The field to group properties by.

public build():DocumentSearch

Build the elastic search request.

public prepareSearch($source):DocumentSearch

Build the search instance itself. May be overridden by concrete factories.

Parameters

Type

Name

Description

IncludeSource

$source