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
$class
protected
string
$class
Current class that's being indexed
$debug
protected
bool
$debug
= false
Debug this build
$fieldResolver
protected
FieldResolver
$fieldResolver
Resolver for fields
$items
protected
null|ArrayList|DataList
$items
Items to create documents for
$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
Return values
array<string|int, mixed> —Documents to be pushed
getClass()
Current class being indexed
public
getClass() : string
Return values
stringgetFieldResolver()
Get the FieldResolver class
public
getFieldResolver() : FieldResolver
Return values
FieldResolvergetItems()
Get the items being indexed
public
getItems() : ArrayList|DataList|null
Return values
ArrayList|DataList|nullgetLogger()
Get the logger
public
getLogger() : LoggerInterface
Return values
LoggerInterfaceisDebug()
Are we debugging?
public
isDebug() : bool
Return values
boolsetClass()
Set the current class to be indexed
public
setClass(string $class) : DocumentFactory
Parameters
- $class : string
Return values
DocumentFactorysetDebug()
Set to true if debugging should be enabled
public
setDebug(bool $debug) : DocumentFactory
Parameters
- $debug : bool
Return values
DocumentFactorysetItems()
Set the items to index
public
setItems(ArrayList|DataList|null $items) : DocumentFactory
Parameters
- $items : ArrayList|DataList|null
Return values
DocumentFactorysetLogger()
Set the logger if needed
public
setLogger(LoggerInterface $logger) : void
Parameters
- $logger : LoggerInterface
addDefaultFields()
Add fields that should always be included
protected
addDefaultFields(Document $doc, DataObject|DataObjectExtension $item) : mixed
Parameters
- $doc : Document
-
Solr Document
- $item : DataObject|DataObjectExtension
-
Item to get the data from
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
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
boolclassIs()
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
boolgetValuesForField()
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>indexGroupMessage()
Show the message about what is being indexed
protected
indexGroupMessage(BaseIndex $index) : void
Parameters
- $index : BaseIndex