Talk:Search

From MediaWiki.org
Jump to: navigation, search

How to implement the search class - by the wikipedian formerly known as Uncle.bungle

It took me days to piece this together so I'm saving it here for posterity (and since I know I can always check back here :p )

$search = SearchEngine::create();
$search->setLimitOffset(5000,0);    /*set max 5000 results starting at result 0
                                        the constructor for SearchEngine will default
                                        this to zero so if not set, no results */
$q = $search->replacePrefixes("searchterm");
$matches = $search->searchText($q);
while( $result = $matches->next() ) {
        $t = $result->getTitle();
        $link = $t->getFullURL();
        echo $link . "\n";
}
Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox