RecordCollection
extends RecordCollection
in package
JSON-based record collection for records from multiple sources.
Tags
Table of Contents
- $config : Config
- Blender configuration
- $errors : array<string|int, mixed>
- Any errors encountered
- $facetFields : array<string|int, mixed>
- Facet fields.
- $filteredFacetCounts : array<string|int, mixed>
- How many facet values have been filtered out, indexed by field.
- $initialResultsBackends : array<string|int, mixed>
- Backends to be used for initial results
- $mappings : array<string|int, mixed>
- Mappings configuration
- $offset : int
- Zero-based offset in complete search result.
- $pointer : int
- Array pointer
- $records : array<string|int, mixed>
- Response records.
- $response : array<string|int, mixed>
- Deserialized SOLR response.
- $source : string
- Source identifier
- $spellcheck : Spellcheck
- Spellcheck information.
- $template : array<string|int, mixed>
- Template of deserialized SOLR response.
- __construct() : void
- Constructor
- add() : void
- Add a record to the collection.
- addError() : void
- Add an error message
- count() : int
- Return number of records in collection.
- current() : RecordInterface
- Return record at current collection index.
- first() : RecordInterface|null
- Return first record in response.
- getCursorMark() : string
- Get cursorMark.
- getErrors() : array<string|int, mixed>
- Return any errors.
- getFacetDelimiter() : string
- Get delimiter for the given facet field
- getFacets() : array<string|int, mixed>
- Return available facets.
- getFilteredFacetCounts() : array<string|int, mixed>
- Get filtered facet data.
- getGroups() : array<string|int, mixed>
- Get grouped results.
- getHighlighting() : array<string|int, mixed>
- Get highlighting details.
- getMaxScore() : mixed
- Gets the highest relevance to search.
- getOffset() : int
- Return offset in the total search result set.
- getPivotFacets() : array<string|int, mixed>
- Return available pivot facets.
- getQueryFacets() : array<string|int, mixed>
- Return available query facets.
- getRecords() : array<string|int, mixed>
- Return records.
- getResponseHeader() : array<string|int, mixed>
- Get response header.
- getSourceIdentifier() : string
- Return the source backend identifier.
- getSpellcheck() : Spellcheck
- Return spellcheck information.
- getTotal() : int
- Return total number of records found.
- has() : bool
- Check if the collection contains the given record
- initBlended() : array<string|int, mixed>
- Initialize blended results
- key() : int
- Return current collection index.
- next() : void
- Move to next collection index.
- replace() : void
- Replace a record in the collection.
- rewind() : void
- Rewind collection index.
- setFacets() : void
- Set facets.
- setFilteredFacetCounts() : void
- Set filtered facet data.
- setSourceIdentifier() : void
- Set the source backend identifier.
- setSourceIdentifiers() : void
- Set the source backend identifiers.
- shuffle() : bool
- Shuffles records.
- slice() : void
- Slice the record list.
- valid() : bool
- Return true if current collection index is valid.
- addErrorsFromBackends() : void
- Store errors from all backends
- collectBackendRecords() : array<string|int, mixed>
- Collect records from all backends to an associative array
- convertFacetValue() : string
- Convert a facet value from a backend
- getBackendAtPosition() : string
- Calculate the backend to be used for a record at the given position
- getBlenderFacetStats() : array<string|int, mixed>
- Get facet counts for Blender backend facet
- getHierarchyParentKeys() : array<string|int, mixed>
- Get parent hierarchy keys for a facet value
- getMergedFacets() : array<string|int, mixed>
- Merge facets
- getRawSpellcheckSuggestions() : array<string|int, mixed>
- Get raw Solr Spellcheck suggestions.
- getSolrParameters() : array<string|int, mixed>
- Get raw Solr input parameters from the response.
- getSpellcheckQuery() : string
- Extract the best matching Spellcheck query from the raw Solr input parameters.
- mapFacetValues() : array<string|int, mixed>
- Map facet values from the backends into a merged list
Properties
$config
Blender configuration
protected
Config
$config
$errors
Any errors encountered
protected
array<string|int, mixed>
$errors
= []
$facetFields
Facet fields.
protected
array<string|int, mixed>
$facetFields
= null
$filteredFacetCounts
How many facet values have been filtered out, indexed by field.
protected
array<string|int, mixed>
$filteredFacetCounts
= []
$initialResultsBackends
Backends to be used for initial results
protected
array<string|int, mixed>
$initialResultsBackends
$mappings
Mappings configuration
protected
array<string|int, mixed>
$mappings
$offset
Zero-based offset in complete search result.
protected
int
$offset
= 0
$pointer
Array pointer
protected
int
$pointer
= 0
$records
Response records.
protected
array<string|int, mixed>
$records
= []
$response
Deserialized SOLR response.
protected
array<string|int, mixed>
$response
$source
Source identifier
protected
string
$source
$spellcheck
Spellcheck information.
protected
Spellcheck
$spellcheck
$template
Template of deserialized SOLR response.
protected
static array<string|int, mixed>
$template
= ['responseHeader' => [], 'response' => ['numFound' => 0, 'start' => 0], 'spellcheck' => ['suggestions' => []], 'facet_counts' => []]
Tags
Methods
__construct()
Constructor
public
__construct([Config $config = null ][, array<string|int, mixed> $mappings = [] ]) : void
Parameters
- $config : Config = null
-
Configuration
- $mappings : array<string|int, mixed> = []
-
Mappings configuration
Return values
void —add()
Add a record to the collection.
public
add(RecordInterface $record[, bool $checkExisting = true ]) : void
Parameters
- $record : RecordInterface
-
Record to add
- $checkExisting : bool = true
-
Whether to check for existing record in the collection (slower, but makes sure there are no duplicates)
Return values
void —addError()
Add an error message
public
addError(mixed $error) : void
Parameters
- $error : mixed
-
Error
Return values
void —count()
Return number of records in collection.
public
count() : int
Return values
int —current()
Return record at current collection index.
public
current() : RecordInterface
Return values
RecordInterface —first()
Return first record in response.
public
first() : RecordInterface|null
Return values
RecordInterface|null —getCursorMark()
Get cursorMark.
public
getCursorMark() : string
Return values
string —getErrors()
Return any errors.
public
getErrors() : array<string|int, mixed>
Each error can be a translatable string or an array that the Flashmessages view helper understands.
Return values
array<string|int, mixed> —getFacetDelimiter()
Get delimiter for the given facet field
public
getFacetDelimiter(string $field) : string
Parameters
- $field : string
-
Facet field
Return values
string —getFacets()
Return available facets.
public
getFacets() : array<string|int, mixed>
Returns an associative array with the field name as key. The value is an associative array of available facets for the field, indexed by facet value.
Return values
array<string|int, mixed> —getFilteredFacetCounts()
Get filtered facet data.
public
getFilteredFacetCounts() : array<string|int, mixed>
Return values
array<string|int, mixed> —getGroups()
Get grouped results.
public
getGroups() : array<string|int, mixed>
Return values
array<string|int, mixed> —getHighlighting()
Get highlighting details.
public
getHighlighting() : array<string|int, mixed>
Return values
array<string|int, mixed> —getMaxScore()
Gets the highest relevance to search.
public
getMaxScore() : mixed
Return values
mixed —getOffset()
Return offset in the total search result set.
public
getOffset() : int
Return values
int —getPivotFacets()
Return available pivot facets.
public
getPivotFacets() : array<string|int, mixed>
Returns an associative array with the internal field name as key. The value is an associative array of the available facets for the field, indexed by facet value.
Return values
array<string|int, mixed> —getQueryFacets()
Return available query facets.
public
getQueryFacets() : array<string|int, mixed>
Returns an associative array with the internal field name as key. The value is an associative array of the available facets for the field, indexed by facet value.
Return values
array<string|int, mixed> —getRecords()
Return records.
public
getRecords() : array<string|int, mixed>
Return values
array<string|int, mixed> —getResponseHeader()
Get response header.
public
getResponseHeader() : array<string|int, mixed>
Return values
array<string|int, mixed> —getSourceIdentifier()
Return the source backend identifier.
public
getSourceIdentifier() : string
Return values
string —getSpellcheck()
Return spellcheck information.
public
getSpellcheck() : Spellcheck
Return values
Spellcheck —getTotal()
Return total number of records found.
public
getTotal() : int
Return values
int —has()
Check if the collection contains the given record
public
has(RecordInterface $record) : bool
Parameters
- $record : RecordInterface
-
Record to check
Return values
bool —initBlended()
Initialize blended results
public
initBlended(array<string|int, mixed> $collections, int $limit, int $blockSize, int $totalCount) : array<string|int, mixed>
Creates a record list from 0 to $limit
Parameters
- $collections : array<string|int, mixed>
-
Array of record collections
- $limit : int
-
Result limit
- $blockSize : int
-
Blending block size
- $totalCount : int
-
Total result count
Return values
array<string|int, mixed> —Remaining records keyed by backend identifier
key()
Return current collection index.
public
key() : int
Return values
int —next()
Move to next collection index.
public
next() : void
Return values
void —replace()
Replace a record in the collection.
public
replace(RecordInterface $record, RecordInterface $replacement) : void
Parameters
- $record : RecordInterface
-
Record to be replaced
- $replacement : RecordInterface
-
Replacement record
Return values
void —rewind()
Rewind collection index.
public
rewind() : void
Return values
void —setFacets()
Set facets.
public
setFacets(array<string|int, mixed> $facets) : void
Parameters
- $facets : array<string|int, mixed>
-
Facet fields
Return values
void —setFilteredFacetCounts()
Set filtered facet data.
public
setFilteredFacetCounts(array<string|int, mixed> $counts) : void
Parameters
- $counts : array<string|int, mixed>
-
Counts of filtered facet values, indexed by field name.
Return values
void —setSourceIdentifier()
Set the source backend identifier.
public
setSourceIdentifier(string $identifier) : void
Parameters
- $identifier : string
-
Backend identifier
Return values
void —setSourceIdentifiers()
Set the source backend identifiers.
public
setSourceIdentifiers(string $recordSourceId[, string $searchBackendId = '' ]) : void
Parameters
- $recordSourceId : string
-
Record source identifier
- $searchBackendId : string = ''
-
Search backend identifier (if different from $recordSourceId)
Return values
void —shuffle()
Shuffles records.
public
shuffle() : bool
Return values
bool —slice()
Slice the record list.
public
slice(int $offset, int $limit) : void
Parameters
- $offset : int
-
Offset
- $limit : int
-
Limit
Return values
void —valid()
Return true if current collection index is valid.
public
valid() : bool
Return values
bool —addErrorsFromBackends()
Store errors from all backends
protected
addErrorsFromBackends(array<string|int, mixed> $collections) : void
Parameters
- $collections : array<string|int, mixed>
-
Array of record collections
Return values
void —collectBackendRecords()
Collect records from all backends to an associative array
protected
collectBackendRecords(array<string|int, mixed> $collections) : array<string|int, mixed>
Parameters
- $collections : array<string|int, mixed>
-
Array of record collections
Return values
array<string|int, mixed> —convertFacetValue()
Convert a facet value from a backend
protected
convertFacetValue(string $value, string $type, string $unmapped, array<string|int, mixed> $valueMap, bool $hierarchical) : string
Parameters
- $value : string
-
Facet value
- $type : string
-
Facet type
- $unmapped : string
-
Unmapped facet handling rule
- $valueMap : array<string|int, mixed>
-
Value map for the field
- $hierarchical : bool
-
Whether the facet is hierarchical
Return values
string —getBackendAtPosition()
Calculate the backend to be used for a record at the given position
protected
getBackendAtPosition(int $position, int $blockSize, array<string|int, mixed> $backendIds, array<string|int, mixed> $initialResultsBackends) : string
Note: This does not take into account whether there are enough records in the source.
Parameters
- $position : int
-
Position
- $blockSize : int
-
Record block size
- $backendIds : array<string|int, mixed>
-
Available backends
- $initialResultsBackends : array<string|int, mixed>
-
List of backends for initial result boosts
Return values
string —getBlenderFacetStats()
Get facet counts for Blender backend facet
protected
getBlenderFacetStats(array<string|int, mixed> $collections) : array<string|int, mixed>
Parameters
- $collections : array<string|int, mixed>
-
Collections
Return values
array<string|int, mixed> —getHierarchyParentKeys()
Get parent hierarchy keys for a facet value
protected
getHierarchyParentKeys(string $value) : array<string|int, mixed>
For example with '2/Main/Sub/Shelf/' the result is: [ '1/Main/Sub/', '0/Main/' ]
Parameters
- $value : string
-
Hierarchical facet value
Return values
array<string|int, mixed> —getMergedFacets()
Merge facets
protected
getMergedFacets(array<string|int, mixed> $collections) : array<string|int, mixed>
Parameters
- $collections : array<string|int, mixed>
-
Result collections
Return values
array<string|int, mixed> —getRawSpellcheckSuggestions()
Get raw Solr Spellcheck suggestions.
protected
getRawSpellcheckSuggestions() : array<string|int, mixed>
Return values
array<string|int, mixed> —getSolrParameters()
Get raw Solr input parameters from the response.
protected
getSolrParameters() : array<string|int, mixed>
Return values
array<string|int, mixed> —getSpellcheckQuery()
Extract the best matching Spellcheck query from the raw Solr input parameters.
protected
getSpellcheckQuery() : string
Return values
string —mapFacetValues()
Map facet values from the backends into a merged list
protected
mapFacetValues(array<string|int, mixed> $collections, array<string|int, mixed> $settings) : array<string|int, mixed>
Parameters
- $collections : array<string|int, mixed>
-
Result collections
- $settings : array<string|int, mixed>
-
Settings for a single facet field