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
$collatedSpellcheck
protected
string
$collatedSpellcheck
Collated spellcheck
$facets
protected
ArrayData
$facets
Facets
$highlight
protected
Highlighting
$highlight
Highlighted items
$index
protected
BaseIndex
$index
Index the query has run on
$matches
protected
stdClass|ArrayList|DataList|DataObject
$matches
Resulting matches from the query on the index
$query
protected
BaseQuery
$query
Query that has been executed
$spellcheck
protected
ArrayList
$spellcheck
Spellcheck results
$totalItems
protected
int
$totalItems
Total items in result
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
getCollatedSpellcheck()
Get the collated spellcheck
public
getCollatedSpellcheck() : string
Return values
stringgetFacets()
Retrieve the facets from the results
public
getFacets() : ArrayData
Return values
ArrayDatagetHighlight()
Get the highlighting
public
getHighlight() : Highlighting|null
Return values
Highlighting|nullgetHighlightByID()
Get the highlight for a specific document
public
getHighlightByID( $docID) : string
Parameters
Return values
stringgetMatches()
Get the matches as an ArrayList and add an excerpt if possible.
public
getMatches() : ArrayList
Return values
ArrayListgetPaginatedMatches()
Get the matches as a Paginated List
public
getPaginatedMatches() : PaginatedList
Return values
PaginatedListgetSpellcheck()
Get the spellchecked results
public
getSpellcheck() : ArrayList
Return values
ArrayListgetTotalItems()
Total items in the result
public
getTotalItems() : int
Return values
intsetCollatedSpellcheck()
Set the collated spellcheck string
public
setCollatedSpellcheck(mixed $collatedSpellcheck) : $this
Parameters
- $collatedSpellcheck : mixed
Return values
$thissetCustomisedMatches()
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
setHighlight()
Set the highlighted items
public
setHighlight( $highlight) : SearchResult
Parameters
Return values
SearchResultsetSpellcheck()
Set the spellcheck list as an ArrayList
public
setSpellcheck(Result|null $spellcheck) : SearchResult
Parameters
- $spellcheck : Result|null
Return values
SearchResultsetTotalItems()
Set the total amount of results
public
setTotalItems( $count) : self
Parameters
Return values
selfbuildFacets()
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
ArrayDatacreateExcerpt()
Generate an excerpt for a DataObject
protected
createExcerpt(string $idField, $match, DataObject $item) : void
Parameters
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
isDataObject()
Check if the match is a DataObject and exists
protected
isDataObject( $match, string $classIDField) : DataObject|bool
Parameters
Return values
DataObject|boolsetFacets()
Set the facets to build
protected
setFacets(FacetSet|null $facets) : $this
Parameters
- $facets : FacetSet|null
Return values
$thissetMatches()
Set the matches from Solarium as an ArrayList
protected
setMatches(array<string|int, mixed> $result) : $this
Parameters
- $result : array<string|int, mixed>