note 54056 added to ref.mnogosearch
| From: | bloodjazman at gmail dot com | Date: | Wed, 22 Jun 2005 12:22:42 +0000 |
| Subject: | note 54056 added to ref.mnogosearch | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-90790@lists.php.net to get a copy of this message | ||
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>
----
Manual Page -- http://www.php.net/manual/en/ref.mnogosearch.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+54056
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54056&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54056&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54056&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54056&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54056&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54056&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+54056&report=yes
Search -- http://master.php.net/manage/user-notes.php