SearchResult()
getArtCat()
getContent()
getNumberOfPages()
getNumberOfResults()
getOccurrence()
getSearchContent()
getSearchResultPage()
getSimilarity()
setDebug()
setOrderedSearchResult()
setReplacement()
__construct()
_debug()
$index
$ordered_search_result
$pages
$rank_structure
$replacement
$result_page
$result_per_page
$results
$search_result
$bDebug
$cfg
$client
$lang
$oDB
Contenido API - SearchResult Object
This object ranks and displays the result of the indexed fulltext search. If you are not comfortable with this API feel free to use your own methods to display the search results. The search result is basically an array with article ID's.
If $search_result = $search->searchIndex($searchword, $searchwordex);
use object with
$oSearchResults = new SearchResult($search_result, 10);
$oSearchResults->setReplacement('', ''); // html-tags to emphasize the located searchwords
$num_res = $oSearchResults->getNumberOfResults(); $num_pages = $oSearchResults->getNumberOfPages(); $res_page = $oSearchResults->getSearchResultPage(1); // first result page foreach ($res_page as $key => $val) { $headline = $oSearchResults->getSearchContent($key, 'HTMLHEAD'); $first_headline = $headline[0]; $text = $oSearchResults->getSearchContent($key, 'HTML'); $first_text = $text[0]; $similarity = $oSearchResults->getSimilarity($key); $iOccurrence = $oSearchResults->getOccurrence($key); }
version | 1.0.0 |
---|---|
author | Willi Man |
copyright | four for business AG <www.4fb.de> |
SearchResult(array $search_result, int $result_per_page, \DB_Contenido $oDB, bool $bDebug)
TODO: One can think of more sophisticated ranking strategies. One could use the content type information for example because a matching word in the headline (CMS_HEADLINE[1]) could be weighted more than a matching word in the text (CMS_HTML[1]).
array
List of article ids
int
Number of items per page
bool
Optional flag to enable debugging
getArtCat($artid) : \Category
todo | Is not job of search, should be outsourced! |
---|
\Category
IdgetContent($art_id, \$art_id $cms_type, $id) : \Content
\$art_id
\Content
of an article, specified by it's content typegetNumberOfPages() : int
int
getNumberOfResults() : int
int
getOccurrence(\$art_id $art_id) : \Number
\$art_id
Id of an article
\Number
of matching searchwords found in articlegetSearchContent(\$cms_type $art_id, \$art_id $cms_type, $cms_nr) : \Content
\$cms_type
Content type
\$art_id
Id of an article
\Content
of an article in search result, specified by its typegetSearchResultPage(int $page_id) : array
int
array
Artices in page $page_idgetSimilarity(\$art_id $art_id) : \Similarity
\$art_id
Id of an article
\Similarity
between searchword and matching word in articlesetDebug(bool $bDebug)
inherited_from | \SearchBaseAbstract::setDebug() |
---|
bool
setOrderedSearchResult($ranked_search, $result_per_page) : void
setReplacement(string $rep1, string $rep2) : void
string
The opening html-tag to emphasize the searchword e.g. ''
string
The closing html-tag e.g. ''
__construct(\DB_Contenido $oDB, bool $bDebug)
inherited_from | \SearchBaseAbstract::__construct() |
---|
bool
Optional, flag to enable debugging
_debug(string $msg, mixed $var)
inherited_from | \SearchBaseAbstract::_debug() |
---|
string
Some text
mixed
The variable to dump
$index : object
$ordered_search_result : array
$pages : int
$rank_structure : array
$replacement : array
$result_page : int
$result_per_page : int
$results : int
$search_result : array
$bDebug : bool
inherited_from | \SearchBaseAbstract::$$bDebug |
---|
$cfg : array
inherited_from | \SearchBaseAbstract::$$cfg |
---|
$client : int
inherited_from | \SearchBaseAbstract::$$client |
---|
$lang : int
inherited_from | \SearchBaseAbstract::$$lang |
---|