The 5th Annual China PHP Conference


(PHP 4 >= 4.0.5, PHP 5 <= 5.0.5, PECL mnogosearch >= 1.0.0)

udm_findPerform search


resource udm_find ( resource $agent , string $query )

Performs a search.

The search itself. The first argument - session, the next one - query itself. To find something just type words you want to find and press SUBMIT button. For example, "mysql odbc". You should not use quotes " in query, they are written here only to divide a query from other text. mnoGoSearch will find all documents that contain word "mysql" and/or word "odbc". Best documents having bigger weights will be displayed first. If you use search mode ALL, search will return documents that contain both (or more) words you entered. In case you use mode ANY, the search will return list of documents that contain any of the words you entered. If you want more advanced results you may use query language. You should select "bool" match mode in the search from.

Elenco dei parametri


A link to Agent, received after call to udm_alloc_agent().


mnoGoSearch understands the following boolean operators:

& - logical AND. For example, "mysql & odbc". mnoGoSearch will find any URLs that contain both "mysql" and "odbc".

| - logical OR. For example "mysql|odbc". mnoGoSearch will find any URLs, that contain word "mysql" or word "odbc".

~ - logical NOT. For example "mysql & ~odbc". mnoGoSearch will find URLs that contain word "mysql" and do not contain word "odbc" at the same time. Note that ~ just excludes given word from results. Query "~odbc" will find nothing!

() - group command to compose more complex queries. For example "(mysql | msql) & ~postgres". Query language is simple and powerful at the same time. Just consider query as usual boolean expression.

Valori restituiti

Returns a result link identifier on success o FALSE in caso di fallimento.

add a note add a note

User Contributed Notes 2 notes

sm_dev_mnogo at u5 dot com
13 years ago
For me (PHP 4.3.3, Mnogo 3.2.15 on FreeBSD) Mnogo doesn't work as described - but very well if done as in the PHP-template distributed by MnogoSearch

I had huge problems getting Udm_Find(... to return anything at all.

All the other calls worked, like udm_get_doc_count(...  but _find seemed to insist on returning nothing, no matter what I tried.

However, I had actually a working installation of mnogo, using the PHP template, so it was just to find the difference in the, BTW impressive, work by Sergey 'gluke' Kartashoff.

The result was surprising, see below. The parameter UDM_PARAM_QUERY is not mentioned in the manual


// This is the real query. Note that Udm_find seems to
  // ignore it, despite the
  // description in the manual

// This is actually also contrary to the manual, but it
  // works. Also in the PHP-template it said
if (Udm_Api_Version() >= 30204) {
} else {
// which contradicts the manual for never versions

$iDoItAsInTheManual = true//Set to false and it works

if ($iDoItAsInTheManual)
$res=Udm_Find($udm_agent, $q);
// This works:
$res=Udm_Find($udm_agent,"anything here, makes no difference!!");

$url = udm_get_res_field(
$res,         //resource res,
0,                 // int row,
UDM_FIELD_URL     // int field

// Fails if $iDoItAsInTheManual==true, otherwise it works fine


I don't know where something has gone wrong but I hope this may help someone save a little time.
matt at nowhere dot dot
14 years ago
Here is a small snipet of code that will perform a search on mnogosearch and (in not so pretty a way) display the results.  Note that it appears that UDM_PARAM_FIRST_DOC starts at 1, but perhaps should be 0.
= trim($_GET['search']);
$mnogo = udm_alloc_agent ('mysql://me:secret@localhost/mnogosearch/');
$mResult = udm_find($mnogo,$searchText);
$totalMatches = udm_get_res_param ($mResult,UDM_PARAM_FOUND);
$pageSize = udm_get_res_param ($mResult,UDM_PARAM_NUM_ROWS);
$firstRow = udm_get_res_param ($mResult,UDM_PARAM_FIRST_DOC);
$lastRow = udm_get_res_param ($mResult,UDM_PARAM_LAST_DOC);
"Your search for <b>$searchText</b> resulted in <b>$totalMatches</b> matches";
"The result set (pagesize) is <b>$pageSize</b>\n";
"The first doc is row <b>$firstRow</b> and the last doc is <b>$lastRow</b>\n";
for (
$i=$firstRow-1;$i<$lastRow;$i++) {
"Match $row:";
'Url: ';
$url = udm_get_res_field ($mResult,$i,UDM_FIELD_URL);
"<a href=\"$url\">$url</a>";
"\nTitle: <b>";
udm_get_res_field ($mResult, $i,UDM_FIELD_TITLE);
"</b>\nMeta Desc:";
udm_get_res_field ($mResult, $i,UDM_FIELD_DESC);
"\nPage Text: <b>\n";
udm_get_res_field ($mResult, $i,UDM_FIELD_TEXT);
To Top