Property | Type | Description | |
---|---|---|---|
$config | |||
$contentType | string | ||
$results | |||
$searchWords | array |
Method | Description | |
---|---|---|
__construct ( |
Constructor takes a compiled SearchConfig which is essentially an array of fields that we will search for text content, along with their corresponding weighting score. | |
setContentType ( string $type ) | Sets the ContentType that we are weighting, that is, what type the results array is. That allows us to map against the configuration to see which fields to scan for relevant text. | |
setResults ( array $results ) | Sets an iterable group of results, this normally comes directly from the database query. | |
setSearchWords ( array $words ) | Sets the words that we want to query against. Normally this comes from the filter in a search, exploded into an array so the words are separated. | |
weight ( ) : array | This is the public method that gets a score for a the set of results. |
Method | Description | |
---|---|---|
buildResultIndex ( Object $result ) : array | This is a simple version of the Vector Space Model. | |
getContentFields ( ) : array | false | Helper method to fetch the fields for an individual ContentType. | |
getResultScore ( Object $result ) : float | This method uses the index built in the method above to do some quick score calculations for each word of the query, versus each word of the index dictionary. |
public __construct ( |
||
$config |
protected buildResultIndex ( Object $result ) : array | ||
$result | Object | A single result to score |
return | array | An array consisting of a count / dictionary of words |
protected getContentFields ( ) : array | false | ||
return | array | false |
protected getResultScore ( Object $result ) : float | ||
$result | Object | |
return | float |
public setContentType ( string $type ) | ||
$type | string |
public setResults ( array $results ) | ||
$results | array |
public setSearchWords ( array $words ) | ||
$words | array |
protected QueryResultset,Bolt\Storage\Query|array $results | ||
return |