VuFind API Documentation

Search2 extends Solr

Hierarchy Tree Data Source (Search2)

This is a base helper class for producing hierarchy Trees.

Tags
category

VuFind

author

Luke O'Sullivan l.osullivan@swansea.ac.uk

author

Samuli Sillanpää samuli.sillanpaa@helsinki.fi

license

http://opensource.org/licenses/gpl-2.0.php GNU General Public License

link

Wiki

Table of Contents

$backendId  : string
Search backend ID used for tree generation.
$batchSize  : int
Record batch size
$cacheDir  : string
Cache directory
$cachePrefix  : string
Hierarchy cache file prefix.
$collectionRoute  : string
Collection page route.
$filters  : array<string|int, mixed>
Filter queries
$formatterManager  : PluginManager
Formatter manager
$hierarchyDriver  : AbstractBase
Hierarchy driver
$recordRoute  : string
Record page route.
$searchService  : Service
Search service
__construct()  : mixed
Constructor.
getCollectionRoute()  : string
Get collection page route.
getFormattedData()  : string
Get formatted data for the specified hierarchy ID.
getJSON()  : string
Get JSON for the specified hierarchy ID.
getRecordRoute()  : string
Get recordpage route.
getXML()  : string
Get XML for the specified hierarchy ID.
setHierarchyDriver()  : AbstractBase
Set the hierarchy driver
supports()  : bool
Does this data source support the specified hierarchy ID?
debug()  : void
Log a debug message.
getDefaultSearchParams()  : array<string|int, mixed>
Get default search parameters shared by cursorMark and legacy methods.
getHierarchyDriver()  : AbstractBase
Get the hierarchy driver
getMapForHierarchy()  : array<string|int, mixed>
Retrieve a map of children for the provided hierarchy.
getRecord()  : array<string|int, mixed>|bool
Get a record from Solr (return false if not found).
log()  : void
Send a message to the logger.
logError()  : void
Log an error message.
logWarning()  : void
Log a warning message.
searchSolr()  : array<string|int, mixed>
Search Solr.
searchSolrCursor()  : array<string|int, mixed>
Search Solr using a cursor.
searchSolrLegacy()  : array<string|int, mixed>
Search Solr using legacy, non-cursorMark method (sometimes needed for backward compatibility, but usually disabled).

Properties

$backendId

Search backend ID used for tree generation.

protected string $backendId

$batchSize

Record batch size

protected int $batchSize = 1000

$cacheDir

Cache directory

protected string $cacheDir = null

$cachePrefix

Hierarchy cache file prefix.

protected string $cachePrefix = 'Search2'

$collectionRoute

Collection page route.

protected string $collectionRoute = 'search2collection'

$filters

Filter queries

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

$recordRoute

Record page route.

protected string $recordRoute = 'search2record'

$searchService

Search service

protected Service $searchService

Methods

__construct()

Constructor.

public __construct(Service $ss, string $backendId, PluginManager $fm[, string $cacheDir = null ][, array<string|int, mixed> $filters = [] ][, int $batchSize = 1000 ]) : mixed
Parameters
$ss : Service

Search service

$backendId : string

Search backend ID

$fm : PluginManager

Formatter manager

$cacheDir : string = null

Directory to hold cache results (optional)

$filters : array<string|int, mixed> = []

Filters to apply to Solr tree queries

$batchSize : int = 1000

Number of records retrieved in a batch

Return values
mixed

getCollectionRoute()

Get collection page route.

public getCollectionRoute() : string
Return values
string

getFormattedData()

Get formatted data for the specified hierarchy ID.

public getFormattedData(string $id, string $format[, array<string|int, mixed> $options = [] ][, string $cacheTemplate = 'tree_%s' ]) : string
Parameters
$id : string

Hierarchy ID.

$format : string

Name of formatter service to use.

$options : array<string|int, mixed> = []

Additional options for JSON generation. (Currently one option is supported: 'refresh' may be set to true to bypass caching).

$cacheTemplate : string = 'tree_%s'

Template for cache filenames

Return values
string

getJSON()

Get JSON for the specified hierarchy ID.

public abstract getJSON(string $id[, array<string|int, mixed> $options = [] ]) : string

Build the JSON file from the Solr fields

Parameters
$id : string

Hierarchy ID.

$options : array<string|int, mixed> = []

Additional options for JSON generation. (Currently one option is supported: 'refresh' may be set to true to bypass caching).

Return values
string

getRecordRoute()

Get recordpage route.

public getRecordRoute() : string
Return values
string

getXML()

Get XML for the specified hierarchy ID.

public abstract getXML(string $id[, array<string|int, mixed> $options = [] ]) : string
Parameters
$id : string

Hierarchy ID.

$options : array<string|int, mixed> = []

Additional options for XML generation.

Return values
string

supports()

Does this data source support the specified hierarchy ID?

public abstract supports(string $id) : bool
Parameters
$id : string

Hierarchy ID.

Return values
bool

debug()

Log a debug message.

protected debug(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

Return values
void

getDefaultSearchParams()

Get default search parameters shared by cursorMark and legacy methods.

protected getDefaultSearchParams() : array<string|int, mixed>
Return values
array<string|int, mixed>

getMapForHierarchy()

Retrieve a map of children for the provided hierarchy.

protected getMapForHierarchy(string $id) : array<string|int, mixed>
Parameters
$id : string

Record ID

Return values
array<string|int, mixed>

getRecord()

Get a record from Solr (return false if not found).

protected getRecord(string $id) : array<string|int, mixed>|bool
Parameters
$id : string

ID to fetch.

Return values
array<string|int, mixed>|bool

log()

Send a message to the logger.

protected log(string $level, string $message[, array<string|int, mixed> $context = [] ][, bool $prependClass = false ]) : void
Parameters
$level : string

Log level

$message : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = false

Prepend class name to message?

Return values
void

logError()

Log an error message.

protected logError(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

Return values
void

logWarning()

Log a warning message.

protected logWarning(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

Return values
void

searchSolr()

Search Solr.

protected searchSolr(string $q[, int $rows = 1073741823 ]) : array<string|int, mixed>
Parameters
$q : string

Search query

$rows : int = 1073741823

Max rows to retrieve (default = int max / 2 since Solr may choke with higher values)

Return values
array<string|int, mixed>

searchSolrCursor()

Search Solr using a cursor.

protected searchSolrCursor(Query $query, int $rows) : array<string|int, mixed>
Parameters
$query : Query

Search query

$rows : int

Page size

Return values
array<string|int, mixed>

searchSolrLegacy()

Search Solr using legacy, non-cursorMark method (sometimes needed for backward compatibility, but usually disabled).

protected searchSolrLegacy(Query $query, int $rows) : array<string|int, mixed>
Parameters
$query : Query

Search query

$rows : int

Page size

Return values
array<string|int, mixed>

Search results