for win32 users, mnogosearch since version 3.2.x
support COM interface
for Reflection API of COM use Visual Studio .NET
-> Tools ..
-> OLE/COM object viewer
- > C:\Program Files\mnoGoSearch\searchcom.dll
simple code
<pre>
<?
define('MNOGOSEARCH_WIN32',
(strtoupper(substr(PHP_OS,0,3))=='WIN') && extension_loaded('COM'));
if (!MNOGOSEARCH_WIN32)
die('MnoGoSearch COM not loaded');
/** Create COM object */
$agent = new COM('MnoGoSearch.GoSearch')
or die('Can\'t create COM object MnoGoSearch.GoSearch');
com_load_typelib('MnoGoSearch.GoSearch');
//mysql://user:passwd@host:port/database/?mode=multi
$agent->DBAddr = $params['DBAddr'];
//buggy, not work
//$agent->DBMode = $params['DBMode'];
$agent->SetCharset($params['Charset']);
$agent->SetCacheMode(true);
$q = 'q='. $query .'&np='. $_REQUEST['page'] .'&ps='. $_REQUEST['pg_size'] .'&m='. $_REQUEST['match'];
$q .= '&wm='. $_REQUEST['word_match'] .'&ul='. $_REQUEST['url_match']. '&wf='. $_REQUEST['where_find'];
$q .= '&typ='. $_REQUEST['content_type'] .'&s='. $_REQUEST['sortby'].'';
//!!! EXECUTE SEARCH QUERY
$result = $agent->Find($q);
if ($agent->ErrorCode>0 || !$result->Valid)
die('MnogoSearch win32 COM Error #'.$agent->ErrorCode.' - '.$agent->ErrorDescription);
$last=$result->LastDoc;
$first=$result->FirstDoc;
$hl_begin = '<span class="mnogosearch_hilight">';
$hl_end= '</span>';
$fetched_result=array();
$i=0;
for($row=$first;$row<=$last;$row++) {
$i=$row-$first;
$line = $result->Line($row);
$fetched_result[$i] = array(
'order'=>$line->Section('Order', $hl_begin, $hl_end),
'url'=> $line->Section('URL', $hl_begin, $hl_end),
'relevance'=>$line->Section('Score', $hl_begin, $hl_end),
'pagerank'=> $line->Section('Pop_Rank', $hl_begin, $hl_end),
'content_type'=> $line->Section('Content-Type', $hl_begin, $hl_end),
'content_length'=> $line->Section('Content-Length', $hl_begin, $hl_end),
'last_time'=> $line->Section('Last-Modified', $hl_begin, $hl_end),
'title'=> $line->Section('title', $hl_begin, $hl_end),
'body'=> $line->Section('body', $hl_begin, $hl_end),
'metadesc'=> $line->Section('meta.description', $hl_begin, $hl_end),
'metakeywords'=> $line->Section('meta.keywords', $hl_begin, $hl_end)
);
}
var_dump($fetched_result);
echo '<br/>search time : '.$result->SearchSeconds;
echo '<br/>words stats :'.$result->WordInfo;
echo '<br/>pg_count: '.$result->NPages;
echo '<br/>total_rows: '. $result->Count;
echo '<br/>first_doc: '.$result->FirstDoc;
echo '<br/>last_doc: '.$result->LastDoc;
echo '<br/>rows_in_page: '.$result->RowsOnPage;
?>
</pre>