PHP Класс Bolt\Storage\Query\SearchWeighter

Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$config SearchConfig
$contentType string
$results QueryResultset | array
$searchWords array

Открытые методы

Метод Описание
__construct ( SearchConfig $config ) 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.

Защищенные методы

Метод Описание
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.

Описание методов

__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.
public __construct ( SearchConfig $config )
$config SearchConfig

getContentFields() защищенный Метод

Helper method to fetch the fields for an individual ContentType.
protected getContentFields ( ) : array | false
Результат array | false

getResultScore() защищенный Метод

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.
protected getResultScore ( Object $result ) : float
$result Object
Результат float

setContentType() публичный Метод

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.
public setContentType ( string $type )
$type string

setResults() публичный Метод

Sets an iterable group of results, this normally comes directly from the database query.
public setResults ( array $results )
$results array

setSearchWords() публичный Метод

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.
public setSearchWords ( array $words )
$words array

weight() публичный Метод

This is the public method that gets a score for a the set of results.
public weight ( ) : array
Результат array An array of scores for each of the corresponding results

Описание свойств

$config защищенное свойство

protected SearchConfig,Bolt\Storage\Query $config
Результат SearchConfig

$contentType защищенное свойство

protected string $contentType
Результат string

$results защищенное свойство

protected QueryResultset,Bolt\Storage\Query|array $results
Результат QueryResultset | array

$searchWords защищенное свойство

protected array $searchWords
Результат array