SilverStripe solr Search

DocumentFactory
in package
Uses Configurable, Extensible, DocumentFactoryTrait, LoggerTrait

Class DocumentFactory Factory to create documents to be pushed to Solr

Table of Contents

Properties

$class  : string
$debug  : bool
$fieldResolver  : FieldResolver
$items  : null|ArrayList|DataList
$logger  : LoggerInterface
The logger to use
$numerals  : array<string|int, mixed>

Methods

__construct()  : mixed
DocumentFactory constructor, sets up the field resolver
buildItems()  : array<string|int, mixed>
Note, it can only take one type of class at a time! So make sure you properly loop and set $class
getClass()  : string
Current class being indexed
getFieldResolver()  : FieldResolver
Get the FieldResolver class
getItems()  : ArrayList|DataList|null
Get the items being indexed
getLogger()  : LoggerInterface
Get the logger
isDebug()  : bool
Are we debugging?
setClass()  : DocumentFactory
Set the current class to be indexed
setDebug()  : DocumentFactory
Set to true if debugging should be enabled
setItems()  : DocumentFactory
Set the items to index
setLogger()  : void
Set the logger if needed
addDefaultFields()  : mixed
Add fields that should always be included
addField()  : void
Add a single field to the Solr index
addToDoc()  : void
Push field to a document
buildFields()  : void
Create the required record for a field
classEquals()  : bool
Check if a base class is an instance of the expected base group
classIs()  : bool
Determine if the given object is one of the given type
getValuesForField()  : array<string|int, mixed>
Use the DataResolver to find the value(s) for a field.
indexGroupMessage()  : void
Show the message about what is being indexed

Properties

$logger

The logger to use

protected LoggerInterface $logger

$numerals

protected static array<string|int, mixed> $numerals = ['tint', 'tfloat', 'tdouble']

Numeral types in Solr

Methods

__construct()

DocumentFactory constructor, sets up the field resolver

public __construct() : mixed

buildItems()

Note, it can only take one type of class at a time! So make sure you properly loop and set $class

public buildItems(array<string|int, mixed> $fields, BaseIndex $index, Query $update) : array<string|int, mixed>
Parameters
$fields : array<string|int, mixed>

Fields to index

$index : BaseIndex

Index to push the documents to

$update : Query

Update Query object

Tags
throws
Exception
Return values
array<string|int, mixed>

Documents to be pushed

getItems()

Get the items being indexed

public getItems() : ArrayList|DataList|null
Return values
ArrayList|DataList|null

getLogger()

Get the logger

public getLogger() : LoggerInterface
Return values
LoggerInterface

isDebug()

Are we debugging?

public isDebug() : bool
Return values
bool

setLogger()

Set the logger if needed

public setLogger(LoggerInterface $logger) : void
Parameters
$logger : LoggerInterface

addField()

Add a single field to the Solr index

protected addField(Document $doc, DataObject $object, array<string|int, mixed> $options) : void
Parameters
$doc : Document

Solr Document

$object : DataObject

Object whose field is to be added

$options : array<string|int, mixed>

Additional options

addToDoc()

Push field to a document

protected addToDoc(Document $doc, array<string|int, mixed> $options, string $type, DBField|string|null $value) : void
Parameters
$doc : Document

Solr document

$options : array<string|int, mixed>

Custom options

$type : string

Type of Solr field

$value : DBField|string|null

Value(s) of the field

buildFields()

Create the required record for a field

protected buildFields(array<string|int, mixed> $fields, Document $doc, DataObject $item, array<string|int, mixed> $boostFields) : void
Parameters
$fields : array<string|int, mixed>

Fields to build a record for

$doc : Document

Document for Solr

$item : DataObject

Object to get the data for

$boostFields : array<string|int, mixed>

Custom set of index-time-boosted fields

Tags
throws
Exception

classEquals()

Check if a base class is an instance of the expected base group

protected classEquals(string|DataObject $class, string $base) : bool
Parameters
$class : string|DataObject

Class to compare

$base : string

Base class

Return values
bool

classIs()

Determine if the given object is one of the given type

protected classIs(string|DataObject $class, array<string|int, mixed>|string $base) : bool
Parameters
$class : string|DataObject

Class to compare

$base : array<string|int, mixed>|string

Class or list of base classes

Return values
bool

getValuesForField()

Use the DataResolver to find the value(s) for a field.

protected getValuesForField(DataObject $object, array<string|int, mixed> $options) : array<string|int, mixed>

Returns an array of values, and if it's multiple, it becomes a long array

Parameters
$object : DataObject

Object to resolve

$options : array<string|int, mixed>

Customised options

Return values
array<string|int, mixed>

        
On this page

Search results