SilverStripe Search

CoreIndexTrait

Trait CoreIndexTrait Getters and Setters for the SolrIndex

Table of Contents

Properties

$class  : array<string|int, string>
$client  : Client
$copyFields  : array<string|int, mixed>
$facetFields  : array<string|int, mixed>
$filterFields  : array<string|int, mixed>
$fulltextFields  : array<string|int, mixed>
$sortFields  : array<string|int, mixed>
$storedFields  : array<string|int, mixed>
$usedAllFields  : bool
usedAllFields is used to determine if the addAllFields method has been called This is to prevent a notice if there is no yml.

Methods

addAllDateFields()  : mixed
Add all date-type fields to the given index
addAllFulltextFields()  : mixed
Add all text-type fields to the given index
addClass()  : self
Add a class to index or query $options is not used anymore, added for backward compatibility
addCopyField()  : $this
Add a copy field
addFacetField()  : $this
Add a facet field
addFilterField()  : $this
Add a filterable field
addFulltextField()  : $this
Add a single Fulltext field
addSortField()  : $this
Add a field to sort on
getClasses()  : array<string|int, mixed>
Get classes
getClient()  : Client
Get the client
getCopyFields()  : array<string|int, mixed>
Return the copy fields
getFacetFields()  : array<string|int, mixed>
getFilterFields()  : array<string|int, mixed>
Get the filter fields
getFulltextFields()  : array<string|int, mixed>
Get the fulltext fields
getSortFields()  : array<string|int, mixed>
Get the sortable fields
getStoredFields()  : array<string|int, mixed>
setClasses()  : $this
Set the classes
setClient()  : $this
Set/override the client
setCopyFields()  : $this
Set the copy fields
setFacetFields()  : $this
Set the fields to use for faceting
setFilterFields()  : $this
Set the filter fields
setFulltextFields()  : $this
Set the fulltext fields
setSortFields()  : $this
Set/override the sortable fields
setStoredFields()  : $this
Stub to be compatible with Solr.
addAllFieldsByType()  : void
Add all database-backed text fields as fulltext searchable fields.
addFulltextFieldsForClass()  : void
Add all fields of a given type to the index

Properties

$class

protected array<string|int, string> $class = []

Classes to index

$copyFields

protected array<string|int, mixed> $copyFields = ['_text' => ['*']]

Fields to copy to the default fields

$facetFields

protected array<string|int, mixed> $facetFields = []

Facet fields

$filterFields

protected array<string|int, mixed> $filterFields = []

Filterable fields

$fulltextFields

protected array<string|int, mixed> $fulltextFields = []

Fulltext fields

$sortFields

protected array<string|int, mixed> $sortFields = []

Sortable fields

$storedFields

protected array<string|int, mixed> $storedFields = []

Stored fields

$usedAllFields

usedAllFields is used to determine if the addAllFields method has been called This is to prevent a notice if there is no yml.

protected bool $usedAllFields = false

Methods

addAllDateFields()

Add all date-type fields to the given index

public addAllDateFields() : mixed
Tags
throws
ReflectionException

addAllFulltextFields()

Add all text-type fields to the given index

public addAllFulltextFields() : mixed
Tags
throws
ReflectionException

addClass()

Add a class to index or query $options is not used anymore, added for backward compatibility

public addClass( $class[, array<string|int, mixed> $options = [] ]) : self
Parameters
$class :
$options : array<string|int, mixed> = []

unused

Return values
self

addCopyField()

Add a copy field

public addCopyField(string $field, array<string|int, mixed> $options) : $this
Parameters
$field : string

Name of the copyfield

$options : array<string|int, mixed>

Array of all fields that should be copied to this copyfield

Return values
$this

addFacetField()

Add a facet field

public addFacetField( $field, array<string|int, mixed> $options) : $this
Parameters
$field :
$options : array<string|int, mixed>
Return values
$this

addFilterField()

Add a filterable field

public addFilterField( $filterField) : $this
Parameters
$filterField :
Return values
$this

addFulltextField()

Add a single Fulltext field

public abstract addFulltextField(string $fulltextField[, array<string|int, mixed> $options = [] ]) : $this
Parameters
$fulltextField : string
$options : array<string|int, mixed> = []
Return values
$this

addSortField()

Add a field to sort on

public addSortField( $sortField) : $this
Parameters
$sortField :
Return values
$this

getClasses()

Get classes

public getClasses() : array<string|int, mixed>
Return values
array<string|int, mixed>

getClient()

Get the client

public getClient() : Client
Return values
Client

getCopyFields()

Return the copy fields

public getCopyFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

getFacetFields()

public getFacetFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

getFilterFields()

Get the filter fields

public getFilterFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

getFulltextFields()

Get the fulltext fields

public getFulltextFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

getSortFields()

Get the sortable fields

public getSortFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

getStoredFields()

public getStoredFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

setClasses()

Set the classes

public setClasses(array<string|int, mixed> $class) : $this
Parameters
$class : array<string|int, mixed>
Return values
$this

setClient()

Set/override the client

public setClient(Client $client) : $this
Parameters
$client : Client
Return values
$this

setCopyFields()

Set the copy fields

public setCopyFields(array<string|int, mixed> $copyField) : $this
Parameters
$copyField : array<string|int, mixed>
Return values
$this

setFacetFields()

Set the fields to use for faceting

public setFacetFields( $fields) : $this
Parameters
$fields :
Return values
$this

setFilterFields()

Set the filter fields

public setFilterFields(array<string|int, mixed> $filterFields) : $this
Parameters
$filterFields : array<string|int, mixed>
Return values
$this

setFulltextFields()

Set the fulltext fields

public setFulltextFields(array<string|int, mixed> $fulltextFields) : $this
Parameters
$fulltextFields : array<string|int, mixed>
Return values
$this

setSortFields()

Set/override the sortable fields

public setSortFields(array<string|int, mixed> $sortFields) : $this
Parameters
$sortFields : array<string|int, mixed>
Return values
$this

setStoredFields()

Stub to be compatible with Solr.

public setStoredFields(array<string|int, mixed> $storedFields) : $this
Parameters
$storedFields : array<string|int, mixed>
Return values
$this

addAllFieldsByType()

Add all database-backed text fields as fulltext searchable fields.

protected addAllFieldsByType([string $dbType = DBString::class ]) : void

For every class included in the index, examines those classes and all parent looking for "DBText" database fields (Varchar, Text, HTMLText, etc) and adds them all as fulltext searchable fields.

Note, there is no check on boosting etc. That needs to be done manually.

Parameters
$dbType : string = DBString::class
Tags
throws
ReflectionException

addFulltextFieldsForClass()

Add all fields of a given type to the index

protected addFulltextFieldsForClass(array<string|int, mixed> $fields[, string $dbType = DBString::class ]) : void
Parameters
$fields : array<string|int, mixed>

The fields on the DataObject

$dbType : string = DBString::class

Class type the reflection should extend

Tags
throws
ReflectionException

        
On this page

Search results