CoreIndex
in package
Uses
Extensible, Configurable, CoreIndexTrait
Table of Contents
Properties
- $class : array<string|int, string>
- $client : Client
- $copyFields : array<string|int, mixed>
- $facetFields : array<string|int, mixed>
- $fieldTypes : mixed
- Field types that can be added Used in init to call build methods from configuration yml
- $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
- doSearch() : mixed
- Execute a search of the given query against the current index.
- 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>
- getFieldsForIndexing() : array<string|int, mixed>
- Get all fields that are required for indexing in a unique way
- getFilterFields() : array<string|int, mixed>
- Get the filter fields
- getFulltextFields() : array<string|int, mixed>
- Get the fulltext fields
- getIndexName() : string
- Get the name of this index.
- getSortFields() : array<string|int, mixed>
- Get the sortable fields
- getStoredFields() : array<string|int, mixed>
- init() : mixed
- Required to initialise the fields.
- 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
- initFromConfig() : void
- Generate the config from yml if possible
Properties
$class
protected
array<string|int, string>
$class
= []
Classes to index
$client
protected
Client
$client
Query client
$copyFields
protected
array<string|int, mixed>
$copyFields
= ['_text' => ['*']]
Fields to copy to the default fields
$facetFields
protected
array<string|int, mixed>
$facetFields
= []
Facet fields
$fieldTypes
Field types that can be added Used in init to call build methods from configuration yml
protected
static mixed
$fieldTypes
= ['FulltextFields', 'SortFields', 'FilterFields', 'BoostedFields', 'CopyFields', 'DefaultField', 'FacetFields', 'StoredFields']
Tags
$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
addAllFulltextFields()
Add all text-type fields to the given index
public
addAllFulltextFields() : mixed
Tags
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
Return values
selfaddCopyField()
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
$thisaddFacetField()
Add a facet field
public
addFacetField( $field, array<string|int, mixed> $options) : $this
Parameters
Return values
$thisaddFilterField()
Add a filterable field
public
addFilterField( $filterField) : $this
Parameters
Return values
$thisaddFulltextField()
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
$thisaddSortField()
Add a field to sort on
public
addSortField( $sortField) : $this
Parameters
Return values
$thisdoSearch()
Execute a search of the given query against the current index.
public
abstract doSearch(CoreQuery $query) : mixed
Parameters
- $query : CoreQuery
getClasses()
Get classes
public
getClasses() : array<string|int, mixed>
Return values
array<string|int, mixed>getClient()
Get the client
public
getClient() : Client
Return values
ClientgetCopyFields()
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>getFieldsForIndexing()
Get all fields that are required for indexing in a unique way
public
getFieldsForIndexing() : 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>getIndexName()
Get the name of this index.
public
abstract getIndexName() : string
Return values
stringgetSortFields()
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>init()
Required to initialise the fields.
public
init() : mixed
It's loaded in to the non-static properties for backward compatibility with FTS Also, it's a tad easier to use this way, loading the other way around would be very memory intensive, as updating the config for each item is not efficient
setClasses()
Set the classes
public
setClasses(array<string|int, mixed> $class) : $this
Parameters
- $class : array<string|int, mixed>
Return values
$thissetClient()
Set/override the client
public
setClient(Client $client) : $this
Parameters
- $client : Client
Return values
$thissetCopyFields()
Set the copy fields
public
setCopyFields(array<string|int, mixed> $copyField) : $this
Parameters
- $copyField : array<string|int, mixed>
Return values
$thissetFacetFields()
Set the fields to use for faceting
public
setFacetFields( $fields) : $this
Parameters
Return values
$thissetFilterFields()
Set the filter fields
public
setFilterFields(array<string|int, mixed> $filterFields) : $this
Parameters
- $filterFields : array<string|int, mixed>
Return values
$thissetFulltextFields()
Set the fulltext fields
public
setFulltextFields(array<string|int, mixed> $fulltextFields) : $this
Parameters
- $fulltextFields : array<string|int, mixed>
Return values
$thissetSortFields()
Set/override the sortable fields
public
setSortFields(array<string|int, mixed> $sortFields) : $this
Parameters
- $sortFields : array<string|int, mixed>
Return values
$thissetStoredFields()
Stub to be compatible with Solr.
public
setStoredFields(array<string|int, mixed> $storedFields) : $this
Parameters
- $storedFields : array<string|int, mixed>
Return values
$thisaddAllFieldsByType()
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
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
initFromConfig()
Generate the config from yml if possible
protected
initFromConfig(array<string|int, mixed>|null $config) : void
Parameters
- $config : array<string|int, mixed>|null