Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : mnoGoSearch Functions

mnoGoSearch Functions

Introduction

These functions allow you to access the mnoGoSearch (former UdmSearch) free search engine. mnoGoSearch is a full-featured search engine software for intranet and internet servers, distributed under the GNU license. mnoGoSearch has a number of unique features, which makes it appropriate for a wide range of applications from search within your site to a specialized search system such as cooking recipes or newspaper search, FTP archive search, news articles search, etc. It offers full-text indexing and searching for HTML, PDF, and text documents. mnoGoSearch consists of two parts. The first is an indexing mechanism (indexer). The purpose of the indexer is to walk through HTTP, FTP, NEWS servers or local files, recursively grabbing all the documents and storing meta-data about that documents in a SQL database in a smart and effective manner. After every document is referenced by its corresponding URL, meta-data is collected by the indexer for later use in a search process. The search is performed via Web interface. C, CGI, PHP and Perl search front ends are included.

More information about mnoGoSearch can be found at » http://www.mnogosearch.org/.

Note:

This extension has been moved to the » PECL repository and is no longer bundled with PHP as of PHP 5.1.0.

Note:

This extension is not available on Windows platforms.

Requirements

Download mnoGosearch from » http://www.mnogosearch.org/ and install it on your system. You need at least version 3.1.10 of mnoGoSearch installed to use these functions.

Installation

In order to have these functions available, you must compile PHP with mnoGosearch support by using the --with-mnogosearch option. If you use this option without specifying the path to mnoGosearch, PHP will look for mnoGosearch under /usr/local/mnogosearch path by default. If you installed mnoGosearch at a different location you should specify it: --with-mnogosearch=DIR.

Information for installing this PECL extension may be found in the manual chapter titled Installation of PECL extensions. Additional information such as new releases, downloads, source files, maintainer information, and a CHANGELOG, can be located here: » http://pecl.php.net/package/mnogosearch.

Note:

PHP contains built-in MySQL access library, which can be used to access MySQL. It is known that mnoGoSearch is not compatible with this built-in library and can work only with generic MySQL libraries. Thus, if you use mnoGoSearch with MySQL, during PHP configuration you have to indicate the directory of your MySQL installation, that was used during mnoGoSearch configuration, i.e. for example: --with-mnogosearch --with-mysql=/usr.

Runtime Configuration

This extension has no configuration directives defined in php.ini.

Resource Types

Predefined Constants

The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.

UDM_FIELD_URLID (integer)
UDM_FIELD_URL (integer)
UDM_FIELD_CONTENT (integer)
UDM_FIELD_TITLE (integer)
UDM_FIELD_KEYWORDS (integer)
UDM_FIELD_DESC (integer)
UDM_FIELD_DESCRIPTION (integer)
UDM_FIELD_TEXT (integer)
UDM_FIELD_SIZE (integer)
UDM_FIELD_RATING (integer)
UDM_FIELD_SCORE (integer)
UDM_FIELD_MODIFIED (integer)
UDM_FIELD_ORDER (integer)
UDM_FIELD_CRC (integer)
UDM_FIELD_CATEGORY (integer)
UDM_FIELD_LANG (integer)
UDM_FIELD_CHARSET (integer)
UDM_PARAM_PAGE_SIZE (integer)
UDM_PARAM_PAGE_NUM (integer)
UDM_PARAM_SEARCH_MODE (integer)
UDM_PARAM_CACHE_MODE (integer)
UDM_PARAM_TRACK_MODE (integer)
UDM_PARAM_PHRASE_MODE (integer)
UDM_PARAM_CHARSET (integer)
UDM_PARAM_LOCAL_CHARSET (integer)
UDM_PARAM_BROWSER_CHARSET (integer)
UDM_PARAM_STOPTABLE (integer)
UDM_PARAM_STOP_TABLE (integer)
UDM_PARAM_STOPFILE (integer)
UDM_PARAM_STOP_FILE (integer)
UDM_PARAM_WEIGHT_FACTOR (integer)
UDM_PARAM_WORD_MATCH (integer)
UDM_PARAM_MAX_WORD_LEN (integer)
UDM_PARAM_MAX_WORDLEN (integer)
UDM_PARAM_MIN_WORD_LEN (integer)
UDM_PARAM_MIN_WORDLEN (integer)
UDM_PARAM_ISPELL_PREFIXES (integer)
UDM_PARAM_ISPELL_PREFIX (integer)
UDM_PARAM_PREFIXES (integer)
UDM_PARAM_PREFIX (integer)
UDM_PARAM_CROSS_WORDS (integer)
UDM_PARAM_CROSSWORDS (integer)
UDM_PARAM_VARDIR (integer)
UDM_PARAM_DATADIR (integer)
UDM_PARAM_HLBEG (integer)
UDM_PARAM_HLEND (integer)
UDM_PARAM_SYNONYM (integer)
UDM_PARAM_SEARCHD (integer)
UDM_PARAM_QSTRING (integer)
UDM_PARAM_REMOTE_ADDR (integer)
UDM_LIMIT_CAT (integer)
UDM_LIMIT_URL (integer)
UDM_LIMIT_TAG (integer)
UDM_LIMIT_LANG (integer)
UDM_LIMIT_DATE (integer)
UDM_PARAM_FOUND (integer)
UDM_PARAM_NUM_ROWS (integer)
UDM_PARAM_WORDINFO (integer)
UDM_PARAM_WORD_INFO (integer)
UDM_PARAM_SEARCHTIME (integer)
UDM_PARAM_SEARCH_TIME (integer)
UDM_PARAM_FIRST_DOC (integer)
UDM_PARAM_LAST_DOC (integer)
UDM_MODE_ALL (integer)
UDM_MODE_ANY (integer)
UDM_MODE_BOOL (integer)
UDM_MODE_PHRASE (integer)
UDM_CACHE_ENABLED (integer)
UDM_CACHE_DISABLED (integer)
UDM_TRACK_ENABLED (integer)
UDM_TRACK_DISABLED (integer)
UDM_PHRASE_ENABLED (integer)
UDM_PHRASE_DISABLED (integer)
UDM_CROSS_WORDS_ENABLED (integer)
UDM_CROSSWORDS_ENABLED (integer)
UDM_CROSS_WORDS_DISABLED (integer)
UDM_CROSSWORDS_DISABLED (integer)
UDM_PREFIXES_ENABLED (integer)
UDM_PREFIX_ENABLED (integer)
UDM_ISPELL_PREFIXES_ENABLED (integer)
UDM_ISPELL_PREFIX_ENABLED (integer)
UDM_PREFIXES_DISABLED (integer)
UDM_PREFIX_DISABLED (integer)
UDM_ISPELL_PREFIXES_DISABLED (integer)
UDM_ISPELL_PREFIX_DISABLED (integer)
UDM_ISPELL_TYPE_AFFIX (integer)
UDM_ISPELL_TYPE_SPELL (integer)
UDM_ISPELL_TYPE_DB (integer)
UDM_ISPELL_TYPE_SERVER (integer)
UDM_MATCH_WORD (integer)
UDM_MATCH_BEGIN (integer)
UDM_MATCH_SUBSTR (integer)
UDM_MATCH_END (integer)

Table of Contents

udm_add_search_limit — Add various search limits
udm_alloc_agent_array — Allocate mnoGoSearch session
udm_alloc_agent — Allocate mnoGoSearch session
udm_api_version — Get mnoGoSearch API version
udm_cat_list — Get all the categories on the same level with the current one
udm_cat_path — Get the path to the current category
udm_check_charset — Check if the given charset is known to mnogosearch
udm_check_stored — Check connection to stored
udm_clear_search_limits — Clear all mnoGoSearch search restrictions
udm_close_stored — Close connection to stored
udm_crc32 — Return CRC32 checksum of given string
udm_errno — Get mnoGoSearch error number
udm_error — Get mnoGoSearch error message
udm_find — Perform search
udm_free_agent — Free mnoGoSearch session
udm_free_ispell_data — Free memory allocated for ispell data
udm_free_res — Free mnoGoSearch result
udm_get_doc_count — Get total number of documents in database
udm_get_res_field — Fetch a result field
udm_get_res_param — Get mnoGoSearch result parameters
udm_hash32 — Return Hash32 checksum of gived string
udm_load_ispell_data — Load ispell data
udm_open_stored — Open connection to stored
udm_set_agent_param — Set mnoGoSearch agent session parameters

Code Examples / Notes » ref.mnogosearch

mikko

Well since the function udm_get_res_param used with UDM_PARAM_NUM_ROWS does infact not get the number of rows on the current page, it can actualy find more rows than specified by UDM_PARAM_PAGE_SIZE, ??? well i had to rewrite the some stuff I also added highlightning since the parameter  UDM_PARAM_HLBEG nor UDM_PARAM_HLEND doesnt seem to work, alot of things here are fairly undocumented, I also found out after reading the Search_Mnogosearch pear class that replacing "\2" and "\3" in the text with HLBEG and HLEND works. well here is the class rewritten (without fetch, just find):
<?php
class MnogoSearch
{
   public    $matches = NULL;
   public    $total   = NULL;
   public    $hilites = array('title', 'text');
   public    $hlbeg   = '<span class="hilite">';
   public    $hlend   = '</span>';
   protected $agent   = NULL;
   protected $res     = NULL;
   public function __construct() {
       $this->agent = udm_alloc_agent('mysql://user:pass@localhost/mnogosearch/');
       $this->set(UDM_PARAM_SEARCH_MODE, UDM_MODE_ALL);
       $this->set(UDM_PARAM_CHARSET, 'iso-8859-1');
       $this->set(UDM_PARAM_BROWSER_CHARSET, 'iso-8859-1');
       $this->set(UDM_PARAM_WORD_MATCH, UDM_MATCH_SUBSTR);
   }
   private function hiLite($t) {
       if ($t == '')
           return '';
       $t = str_replace("\2", $this->hlbeg, $t);
       $t = str_replace("\3", $this->hlend, $t);
       return $t;
   }
   public function set($k, $v) {
       udm_set_agent_param($this->agent, $k, $v);
   }
   public function find($q, $page=0, $rows=10) {
       if ($page < 0 || $rows <= 0) {
           $page = 0;
           $rows = 10;
       }
       $this->set(UDM_PARAM_PAGE_SIZE, $rows);
       $this->set(UDM_PARAM_PAGE_NUM, $page);
       $this->res = udm_find($this->agent, $q);
       $this->total = udm_get_res_param($this->res, UDM_PARAM_FOUND);
       $found = udm_get_res_param($this->res, UDM_PARAM_NUM_ROWS);
       if($found) {
           $b = udm_get_res_param($this->res, UDM_PARAM_FIRST_DOC);
           $e = udm_get_res_param($this->res, UDM_PARAM_LAST_DOC);
           $rows = $e - $b + 1;
           $fields = array('urlid', 'url', 'content', 'title', 'keywords', 'desc',
                           'text', 'size', 'rating', 'modified', 'order', 'crc', 'category',
                           'lang', 'charset', 'siteid', 'pop_rank', 'originid');
           for($i=0; $i<$rows; $i++){
               for($j=0; $j<count($fields); $j++) {
                   $this->matches[$i][$fields[$j]] = udm_get_res_field($this->res, $i, $j+1);
               }
               foreach($this->hilites as $hilite) {
                   $this->matches[$i][$hilite] = $this->hiLite($this->matches[$i][$hilite]);
               }
           }
           return $rows;
       } else {
           return FALSE;
       }
   }
   public function __destruct() {
       udm_free_agent($this->agent);
       if (isset($this->res)) {
           udm_free_res($this->res);
       }
   }
}
?>
Im thinking, maybe swish-e is better ? :)


brasnah-dev

There is always a collisions for FTP name between PHP releease 4.2.0-dev and mnogosearch 3.2.3. So, first compile mnogosearch with --disable-ftp.

marten dot gustafsson

The name collision between php's builtin FTP functions and mnoGo's have been fixed since version 3.1.14 of mnoGoSearch according to;  http://www.mnogosearch.ru/history.html

php-install

I have found that if you compile php with "--with-ftp and --with-mnogosearch=/dir" you must compile and build mnogosearch with "--disable-ftp" first. There are some naming conflicts between php's ftp libs and mno's ftp libs.
Hope this helps


m

I finally got PHP 4.2.1 to compile with mnoGoSearch 3.2.2 ; trick is to build the shared mnoGoSearch and not the static version (opposite from mnoGoSearch defaults), and not to use --disable-rpath in PHP.

bloodjazman

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>


Change Language


Follow Navioo On Twitter
.NET Functions
Apache-specific Functions
Alternative PHP Cache
Advanced PHP debugger
Array Functions
Aspell functions [deprecated]
BBCode Functions
BCMath Arbitrary Precision Mathematics Functions
PHP bytecode Compiler
Bzip2 Compression Functions
Calendar Functions
CCVS API Functions [deprecated]
Class/Object Functions
Classkit Functions
ClibPDF Functions [deprecated]
COM and .Net (Windows)
Crack Functions
Character Type Functions
CURL
Cybercash Payment Functions
Credit Mutuel CyberMUT functions
Cyrus IMAP administration Functions
Date and Time Functions
DB++ Functions
Database (dbm-style) Abstraction Layer Functions
dBase Functions
DBM Functions [deprecated]
dbx Functions
Direct IO Functions
Directory Functions
DOM Functions
DOM XML Functions
enchant Functions
Error Handling and Logging Functions
Exif Functions
Expect Functions
File Alteration Monitor Functions
Forms Data Format Functions
Fileinfo Functions
filePro Functions
Filesystem Functions
Filter Functions
Firebird/InterBase Functions
Firebird/Interbase Functions (PDO_FIREBIRD)
FriBiDi Functions
FrontBase Functions
FTP Functions
Function Handling Functions
GeoIP Functions
Gettext Functions
GMP Functions
gnupg Functions
Net_Gopher
Haru PDF Functions
hash Functions
HTTP
Hyperwave Functions
Hyperwave API Functions
i18n Functions
IBM Functions (PDO_IBM)
IBM DB2
iconv Functions
ID3 Functions
IIS Administration Functions
Image Functions
Imagick Image Library
IMAP
Informix Functions
Informix Functions (PDO_INFORMIX)
Ingres II Functions
IRC Gateway Functions
PHP / Java Integration
JSON Functions
KADM5
LDAP Functions
libxml Functions
Lotus Notes Functions
LZF Functions
Mail Functions
Mailparse Functions
Mathematical Functions
MaxDB PHP Extension
MCAL Functions
Mcrypt Encryption Functions
MCVE (Monetra) Payment Functions
Memcache Functions
Mhash Functions
Mimetype Functions
Ming functions for Flash
Miscellaneous Functions
mnoGoSearch Functions
Microsoft SQL Server Functions
Microsoft SQL Server and Sybase Functions (PDO_DBLIB)
Mohawk Software Session Handler Functions
mSQL Functions
Multibyte String Functions
muscat Functions
MySQL Functions
MySQL Functions (PDO_MYSQL)
MySQL Improved Extension
Ncurses Terminal Screen Control Functions
Network Functions
Newt Functions
NSAPI-specific Functions
Object Aggregation/Composition Functions
Object property and method call overloading
Oracle Functions
ODBC Functions (Unified)
ODBC and DB2 Functions (PDO_ODBC)
oggvorbis
OpenAL Audio Bindings
OpenSSL Functions
Oracle Functions [deprecated]
Oracle Functions (PDO_OCI)
Output Control Functions
Ovrimos SQL Functions
Paradox File Access
Parsekit Functions
Process Control Functions
Regular Expression Functions (Perl-Compatible)
PDF Functions
PDO Functions
Phar archive stream and classes
PHP Options&Information
POSIX Functions
Regular Expression Functions (POSIX Extended)
PostgreSQL Functions
PostgreSQL Functions (PDO_PGSQL)
Printer Functions
Program Execution Functions
PostScript document creation
Pspell Functions
qtdom Functions
Radius
Rar Functions
GNU Readline
GNU Recode Functions
RPM Header Reading Functions
runkit Functions
SAM - Simple Asynchronous Messaging
Satellite CORBA client extension [deprecated]
SCA Functions
SDO Functions
SDO XML Data Access Service Functions
SDO Relational Data Access Service Functions
Semaphore
SESAM Database Functions
PostgreSQL Session Save Handler
Session Handling Functions
Shared Memory Functions
SimpleXML functions
SNMP Functions
SOAP Functions
Socket Functions
Standard PHP Library (SPL) Functions
SQLite Functions
SQLite Functions (PDO_SQLITE)
Secure Shell2 Functions
Statistics Functions
Stream Functions
String Functions
Subversion Functions
Shockwave Flash Functions
Swish Functions
Sybase Functions
TCP Wrappers Functions
Tidy Functions
Tokenizer Functions
Unicode Functions
URL Functions
Variable Handling Functions
Verisign Payflow Pro Functions
vpopmail Functions
W32api Functions
WDDX Functions
win32ps Functions
win32service Functions
xattr Functions
xdiff Functions
XML Parser Functions
XML-RPC Functions
XMLReader functions
XMLWriter Functions
XSL functions
XSLT Functions
YAZ Functions
YP/NIS Functions
Zip File Functions
Zlib Compression Functions
eXTReMe Tracker