UdmSearch: Re: Creation of a new feature of Mnogo PHP Search facility.
This "SELECT count(*) FROM url" will mean the TOTAL number of documents. Note that it is actually not the number of searchable documents, because some of them may be not indexed yet when database is being populated during first indexing. Probably "SELECT count(*) FROM url WHERE status IN (200,304)" or "SELECT count(*) FROM url WHERE docsize0" will be closer to the number of searchable documents, but this will work slowly. Also note that not all databases return count(*) quickly like MySQL, for example, PostgreSQL will scan whole table to calculate the count. We'll add new template variable responsible for this, but it seems it will be useful with MySQL only. Laurent LEVIER wrote: Hi Guys, I wished to display the number of indexed URLs. To be able to do this nicely (using templates), I did the following changes: *** in init.inc, in the global variables declarations, i added: global $numurlsdb; *** Then, after db_init($dbtype,$dbname,$dbhost,$dbuser,$dbpass,$dbport,$dbodbc,$dbodbc_cursor_type); if ($db_format == '3.1') { $cs=load_cs($cat); $cp=load_cp($cat); } *** I added: // -- // Laurent LEVIER changes to add NU code to return number of indexed URLs // -- $query ="SELECT count(*) from url"; if($DEBUG) echo "last_parse(): ",$query,"BRHR"; if (!$res=db_query($query)) print_error_local('Query error: '.$query."\nBR".db_error()); $numurlsdb="10"; if ($row=db_fetchrow($res)) { $numurlsdb=$row[0]; } db_freeresult($res); *** To parse the data nicely, I changed template.inc: *** I added in all the ereg_replace a new one. I put it after lang_url_translation: $str=ereg_replace('\$NU', $numurlsdb, $str); *** and of course, the global declaration in the print_template function: global $numurlsdb; *** It works fine. In my case, adding this in the top section of the template: $NU URLs exists in the database. This new keyword is now replaced with the number of urls in table url. As this query is SQL92 conformant, it should work everywhere, so no need to deal with SQL server format. Please confirm this represent the real number of URL that can be searched. Enjoy! Laurent LEVIER IT Systems Networks, Unix System Engineer Security Specialist Argosnet Security Server : http://www.Argosnet.com "Le Veilleur Technologique", "The Technology Watcher" __ If you want to unsubscribe send "unsubscribe udmsearch" to [EMAIL PROTECTED]
Re: UdmSearch: Re: Creation of a new feature of Mnogo PHP Search facility.
Well, $ndocs variable has been added into 3.1.11 sources. Regards. Alexander Barkov wrote: This "SELECT count(*) FROM url" will mean the TOTAL number of documents. Note that it is actually not the number of searchable documents, because some of them may be not indexed yet when database is being populated during first indexing. Probably "SELECT count(*) FROM url WHERE status IN (200,304)" or "SELECT count(*) FROM url WHERE docsize0" will be closer to the number of searchable documents, but this will work slowly. Also note that not all databases return count(*) quickly like MySQL, for example, PostgreSQL will scan whole table to calculate the count. We'll add new template variable responsible for this, but it seems it will be useful with MySQL only. Laurent LEVIER wrote: Hi Guys, I wished to display the number of indexed URLs. To be able to do this nicely (using templates), I did the following changes: *** in init.inc, in the global variables declarations, i added: global $numurlsdb; *** Then, after db_init($dbtype,$dbname,$dbhost,$dbuser,$dbpass,$dbport,$dbodbc,$dbodbc_cursor_type); if ($db_format == '3.1') { $cs=load_cs($cat); $cp=load_cp($cat); } *** I added: // -- // Laurent LEVIER changes to add NU code to return number of indexed URLs // -- $query ="SELECT count(*) from url"; if($DEBUG) echo "last_parse(): ",$query,"BRHR"; if (!$res=db_query($query)) print_error_local('Query error: '.$query."\nBR".db_error()); $numurlsdb="10"; if ($row=db_fetchrow($res)) { $numurlsdb=$row[0]; } db_freeresult($res); *** To parse the data nicely, I changed template.inc: *** I added in all the ereg_replace a new one. I put it after lang_url_translation: $str=ereg_replace('\$NU', $numurlsdb, $str); *** and of course, the global declaration in the print_template function: global $numurlsdb; *** It works fine. In my case, adding this in the top section of the template: $NU URLs exists in the database. This new keyword is now replaced with the number of urls in table url. As this query is SQL92 conformant, it should work everywhere, so no need to deal with SQL server format. Please confirm this represent the real number of URL that can be searched. Enjoy! Laurent LEVIER IT Systems Networks, Unix System Engineer Security Specialist Argosnet Security Server : http://www.Argosnet.com "Le Veilleur Technologique", "The Technology Watcher" __ If you want to unsubscribe send "unsubscribe udmsearch" to [EMAIL PROTECTED] __ If you want to unsubscribe send "unsubscribe udmsearch" to [EMAIL PROTECTED]
UdmSearch: Re: Creation of a new feature of Mnogo PHP Search facility.
Ok, I will change my query with the first one. After a test, yes it slows the display of the page. So I changed a bit my howto. I removed the init.inc changes and put into template.inc after the lang_url_translation treatment: // -- // Laurent LEVIER changes to add NU code to return number of indexed URLs // -- if (ereg('\$NU',$str)) { $query ="SELECT count(*) FROM url WHERE status IN (200,304)"; if($DEBUG) echo "last_parse(): ",$query,"BRHR"; if (!$res=db_query($query)) print_error_local('Query error: '.$query."\n BR".db_error()); $numurlsdb="10"; if ($row=db_fetchrow($res)) { $numurlsdb=$row[0]; } db_freeresult($res); $str=ereg_replace('\$NU', $numurlsdb, $str); } // -- // Laurent LEVIER changes to add NU code to return number of indexed URLs // -- Works also fine, and have the advantage to be included easily. Only activated when you request the feature :) @+/L At 12:41 15/02/2001 +0400, Alexander Barkov wrote: This "SELECT count(*) FROM url" will mean the TOTAL number of documents. Note that it is actually not the number of searchable documents, because some of them may be not indexed yet when database is being populated during first indexing. Probably "SELECT count(*) FROM url WHERE status IN (200,304)" or "SELECT count(*) FROM url WHERE docsize0" will be closer to the number of searchable documents, but this will work slowly. Also note that not all databases return count(*) quickly like MySQL, for example, PostgreSQL will scan whole table to calculate the count. We'll add new template variable responsible for this, but it seems it will be useful with MySQL only. Laurent LEVIER wrote: Hi Guys, I wished to display the number of indexed URLs. To be able to do this nicely (using templates), I did the following changes: *** in init.inc, in the global variables declarations, i added: global $numurlsdb; *** Then, after db_init($dbtype,$dbname,$dbhost,$dbuser,$dbpass,$dbport,$dbodbc,$dbodbc_cursor_type); if ($db_format == '3.1') { $cs=load_cs($cat); $cp=load_cp($cat); } *** I added: // -- // Laurent LEVIER changes to add NU code to return number of indexed URLs // -- $query ="SELECT count(*) from url"; if($DEBUG) echo "last_parse(): ",$query,"BRHR"; if (!$res=db_query($query)) print_error_local('Query error: '.$query."\nBR".db_error()); $numurlsdb="10"; if ($row=db_fetchrow($res)) { $numurlsdb=$row[0]; } db_freeresult($res); *** To parse the data nicely, I changed template.inc: *** I added in all the ereg_replace a new one. I put it after lang_url_translation: $str=ereg_replace('\$NU', $numurlsdb, $str); *** and of course, the global declaration in the print_template function: global $numurlsdb; *** It works fine. In my case, adding this in the top section of the template: $NU URLs exists in the database. This new keyword is now replaced with the number of urls in table url. As this query is SQL92 conformant, it should work everywhere, so no need to deal with SQL server format. Please confirm this represent the real number of URL that can be searched. Enjoy! Laurent LEVIER IT Systems Networks, Unix System Engineer Security Specialist Argosnet Security Server : http://www.Argosnet.com "Le Veilleur Technologique", "The Technology Watcher" Laurent LEVIER IT Systems Networks, Unix System Engineer Security Specialist Argosnet Security Server : http://www.Argosnet.com "Le Veilleur Technologique", "The Technology Watcher" __ If you want to unsubscribe send "unsubscribe udmsearch" to [EMAIL PROTECTED]
UdmSearch: Re: Creation of a new feature of Mnogo PHP Search facility.
May I suggest? Probably it will be more useful to create a separate table with one column and one raw and store current documents number there: CREATE TABLE ndocs (ndocs int); Then after every reindexing run this: DELETE FROM ndocs; INSERT INTO ndocs SELECT count(*) FROM url WHERE . You may write a script which will run indexer and then execute these queries. Or you may also add these queries execition into crontab. Then in search.php use: SELECT ndocs FROM ndocs to get last calculated doc number. It will be much faster when count(*) with WHERE clause. Laurent LEVIER wrote: Ok, I will change my query with the first one. After a test, yes it slows the display of the page. So I changed a bit my howto. I removed the init.inc changes and put into template.inc after the lang_url_translation treatment: // -- // Laurent LEVIER changes to add NU code to return number of indexed URLs // -- if (ereg('\$NU',$str)) { $query ="SELECT count(*) FROM url WHERE status IN (200,304)"; if($DEBUG) echo "last_parse(): ",$query,"BRHR"; if (!$res=db_query($query)) print_error_local('Query error: '.$query."\n BR".db_error()); $numurlsdb="10"; if ($row=db_fetchrow($res)) { $numurlsdb=$row[0]; } db_freeresult($res); $str=ereg_replace('\$NU', $numurlsdb, $str); } // -- // Laurent LEVIER changes to add NU code to return number of indexed URLs // -- Works also fine, and have the advantage to be included easily. Only activated when you request the feature :) @+/L At 12:41 15/02/2001 +0400, Alexander Barkov wrote: This "SELECT count(*) FROM url" will mean the TOTAL number of documents. Note that it is actually not the number of searchable documents, because some of them may be not indexed yet when database is being populated during first indexing. Probably "SELECT count(*) FROM url WHERE status IN (200,304)" or "SELECT count(*) FROM url WHERE docsize0" will be closer to the number of searchable documents, but this will work slowly. Also note that not all databases return count(*) quickly like MySQL, for example, PostgreSQL will scan whole table to calculate the count. We'll add new template variable responsible for this, but it seems it will be useful with MySQL only. Laurent LEVIER wrote: Hi Guys, I wished to display the number of indexed URLs. To be able to do this nicely (using templates), I did the following changes: *** in init.inc, in the global variables declarations, i added: global $numurlsdb; *** Then, after db_init($dbtype,$dbname,$dbhost,$dbuser,$dbpass,$dbport,$dbodbc,$dbodbc_cursor_type); if ($db_format == '3.1') { $cs=load_cs($cat); $cp=load_cp($cat); } *** I added: // -- // Laurent LEVIER changes to add NU code to return number of indexed URLs // -- $query ="SELECT count(*) from url"; if($DEBUG) echo "last_parse(): ",$query,"BRHR"; if (!$res=db_query($query)) print_error_local('Query error: '.$query."\nBR".db_error()); $numurlsdb="10"; if ($row=db_fetchrow($res)) { $numurlsdb=$row[0]; } db_freeresult($res); *** To parse the data nicely, I changed template.inc: *** I added in all the ereg_replace a new one. I put it after lang_url_translation: $str=ereg_replace('\$NU', $numurlsdb, $str); *** and of course, the global declaration in the print_template function: global $numurlsdb; *** It works fine. In my case, adding this in the top section of the template: $NU URLs exists in the database. This new keyword is now replaced with the number of urls in table url. As this query is SQL92 conformant, it should work everywhere, so no need to deal with SQL server format. Please confirm this represent the real number of URL that can be searched. Enjoy! Laurent LEVIER IT Systems Networks, Unix System Engineer Security Specialist Argosnet Security Server : http://www.Argosnet.com "Le Veilleur Technologique", "The Technology Watcher" Laurent LEVIER IT Systems Networks, Unix System Engineer Security Specialist Argosnet Security Server : http://www.Argosnet.com "Le Veilleur Technologique", "The Technology Watcher" __ If you want to unsubscribe send "unsubscribe udmsearch" to [EMAIL PROTECTED]