SilverStripe solr Search

SearchResult extends ViewableData
in package
Uses SearchResultGetTrait, SearchResultSetTrait

Class SearchResult is the combined result in a SilverStripe readable way

Each of the requested features of a BaseQuery are generated to be easily accessible in the controller. In the controller, each required item can be accessed through the resulting method in this class.

Table of Contents

Properties

$collatedSpellcheck  : string
$facets  : ArrayData
$highlight  : Highlighting
$index  : BaseIndex
$matches  : stdClass|ArrayList|DataList|DataObject
$query  : BaseQuery
$spellcheck  : ArrayList
$totalItems  : int

Methods

__construct()  : mixed
SearchResult constructor.
getCollatedSpellcheck()  : string
Get the collated spellcheck
getFacets()  : ArrayData
Retrieve the facets from the results
getHighlight()  : Highlighting|null
Get the highlighting
getHighlightByID()  : string
Get the highlight for a specific document
getMatches()  : ArrayList
Get the matches as an ArrayList and add an excerpt if possible.
getPaginatedMatches()  : PaginatedList
Get the matches as a Paginated List
getSpellcheck()  : ArrayList
Get the spellchecked results
getTotalItems()  : int
Total items in the result
setCollatedSpellcheck()  : $this
Set the collated spellcheck string
setCustomisedMatches()  : mixed
Allow overriding of matches with a custom result. Accepts anything you like, mostly
setHighlight()  : SearchResult
Set the highlighted items
setSpellcheck()  : SearchResult
Set the spellcheck list as an ArrayList
setTotalItems()  : self
Set the total amount of results
buildFacets()  : ArrayData
Build the given list of key-value pairs in to a SilverStripe useable array
createExcerpt()  : void
Generate an excerpt for a DataObject
createFacet()  : array<string|int, mixed>
Create facets from each faceted class
getClassFacets()  : void
Get the facets for each class and their count
isDataObject()  : DataObject|bool
Check if the match is a DataObject and exists
setFacets()  : $this
Set the facets to build
setMatches()  : $this
Set the matches from Solarium as an ArrayList

Properties

$matches

protected stdClass|ArrayList|DataList|DataObject $matches

Resulting matches from the query on the index

Methods

__construct()

SearchResult constructor.

public __construct(Result $result, BaseQuery $query, BaseIndex $index) : mixed

Funnily enough, the $result contains the actual results, and has methods for the other things. See Solarium docs for this.

Parameters
$result : Result
$query : BaseQuery
$index : BaseIndex

getCollatedSpellcheck()

Get the collated spellcheck

public getCollatedSpellcheck() : string
Return values
string

getFacets()

Retrieve the facets from the results

public getFacets() : ArrayData
Return values
ArrayData

getHighlight()

Get the highlighting

public getHighlight() : Highlighting|null
Return values
Highlighting|null

getHighlightByID()

Get the highlight for a specific document

public getHighlightByID( $docID) : string
Parameters
$docID :
Return values
string

getMatches()

Get the matches as an ArrayList and add an excerpt if possible.

public getMatches() : ArrayList

Return values
ArrayList

getPaginatedMatches()

Get the matches as a Paginated List

public getPaginatedMatches() : PaginatedList
Return values
PaginatedList

getSpellcheck()

Get the spellchecked results

public getSpellcheck() : ArrayList
Return values
ArrayList

getTotalItems()

Total items in the result

public getTotalItems() : int
Return values
int

setCollatedSpellcheck()

Set the collated spellcheck string

public setCollatedSpellcheck(mixed $collatedSpellcheck) : $this
Parameters
$collatedSpellcheck : mixed
Return values
$this

setCustomisedMatches()

Allow overriding of matches with a custom result. Accepts anything you like, mostly

public setCustomisedMatches(stdClass|ArrayList|DataList|DataObject $matches) : mixed
Parameters
$matches : stdClass|ArrayList|DataList|DataObject

setSpellcheck()

Set the spellcheck list as an ArrayList

public setSpellcheck(Result|null $spellcheck) : SearchResult
Parameters
$spellcheck : Result|null
Return values
SearchResult

setTotalItems()

Set the total amount of results

public setTotalItems( $count) : self
Parameters
$count :
Return values
self

buildFacets()

Build the given list of key-value pairs in to a SilverStripe useable array

protected buildFacets(FacetSet|null $facets) : ArrayData
Parameters
$facets : FacetSet|null
Return values
ArrayData

createExcerpt()

Generate an excerpt for a DataObject

protected createExcerpt(string $idField,  $match, DataObject $item) : void
Parameters
$idField : string
$match :
$item : DataObject

createFacet()

Create facets from each faceted class

protected createFacet(FacetSet $facets, array<string|int, mixed> $options, string $class, array<string|int, mixed> $facetArray) : array<string|int, mixed>
Parameters
$facets : FacetSet
$options : array<string|int, mixed>
$class : string
$facetArray : array<string|int, mixed>
Return values
array<string|int, mixed>

getClassFacets()

Get the facets for each class and their count

protected getClassFacets( $class, array<string|int, mixed> $values, ArrayList &$results) : void
Parameters
$class :
$values : array<string|int, mixed>
$results : ArrayList

isDataObject()

Check if the match is a DataObject and exists

protected isDataObject( $match, string $classIDField) : DataObject|bool
Parameters
$match :
$classIDField : string
Return values
DataObject|bool

setFacets()

Set the facets to build

protected setFacets(FacetSet|null $facets) : $this
Parameters
$facets : FacetSet|null
Return values
$this

setMatches()

Set the matches from Solarium as an ArrayList

protected setMatches(array<string|int, mixed> $result) : $this
Parameters
$result : array<string|int, mixed>
Return values
$this

        
On this page

Search results