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 cSearchResult($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 |
__construct(array $search_result, int $result_per_page, \cDb $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]).
arrayList of article ids
intNumber of items per page
boolOptional flag to enable debugging
getArtCat($artid) : \Category
| todo | Is not job of search, should be outsourced! |
|---|
\CategoryIdgetContent($art_id, $cms_type, $id) : \Content
Id of an article
\Contentof an article, specified by it's content typegetNumberOfPages() : int
intgetNumberOfResults() : int
intgetOccurrence($art_id) : \Number
Id of an article
\Numberof matching searchwords found in articlegetSearchContent($art_id, $cms_type, $cms_nr) : \Content
Id of an article
Content type
\Contentof an article in search result, specified by its typegetSearchResultPage(int $page_id) : array
int
arrayArtices in page $page_idgetSimilarity($art_id) : \Similarity
Id of an article
\Similaritybetween searchword and matching word in articlesetDebug(bool $bDebug)
| inherited_from | \cSearchBaseAbstract::setDebug() |
|---|
bool
setOrderedSearchResult($ranked_search, $result_per_page) : void
setReplacement(string $rep1, string $rep2) : void
stringThe opening html-tag to emphasize the searchword e.g. ''
stringThe closing html-tag e.g. ''
_debug(string $msg, mixed $var)
| inherited_from | \cSearchBaseAbstract::_debug() |
|---|
stringSome text
mixedThe variable to dump
$_index : object
$_orderedSearchResult : array
$_pages : int
$_rankStructure : array
$_replacement : array
$_resultPage : int
$_resultPerPage : int
$_results : int
$_searchResult : array
..
$bDebug : bool
| inherited_from | \cSearchBaseAbstract::$$bDebug |
|---|
$cfg : array
| inherited_from | \cSearchBaseAbstract::$$cfg |
|---|
$client : int
| inherited_from | \cSearchBaseAbstract::$$client |
|---|
$lang : int
| inherited_from | \cSearchBaseAbstract::$$lang |
|---|