PhpDig.net

Go Back   PhpDig.net > PhpDig Forums > How-to Forum

Reply
 
Thread Tools
Old 04-09-2004, 09:04 AM   #1
peter_johnson
Green Mole
 
Join Date: Apr 2004
Posts: 1
Search results ordered by update_date

Hi,
Is it possible to classify the search results according the update date ?
Best regards
Peter
peter_johnson is offline   Reply With Quote
Old 04-09-2004, 05:27 PM   #2
vinyl-junkie
Purple Mole
 
Join Date: Jan 2004
Posts: 694
First of all, welcome to the phpDig forum, Peter. We're glad to have you here.

This is untested, but please find the following code in search_function.php:
PHP Code:
$query "SELECT sites.site_url, sites.port, spider.path,spider.file,spider.first_words,
sites.site_id,spider.spider_id,spider.last_modified,spider.md5 "
."FROM ".PHPDIG_DB_PREFIX."spider AS 
spider, "
.PHPDIG_DB_PREFIX."sites AS sites "
."WHERE spider.spider_id=$spider_id AND sites.site_id = spider.site_id"
and change it like so:
PHP Code:
$query "SELECT sites.site_url, sites.port, spider.path,spider.file,spider.first_words,
sites.site_id,spider.spider_id,spider.last_modified,spider.md5 "
                      
."FROM ".PHPDIG_DB_PREFIX."spider AS spider, ".PHPDIG_DB_PREFIX."sites AS sites "
                      
."WHERE spider.spider_id=$spider_id AND sites.site_id = spider.site_id ORDER BY spider.last_modified"
Be sure to remove any word wrapping in the above code.

Let us know if this worked, too. Thanks!
vinyl-junkie is offline   Reply With Quote
Old 06-09-2004, 01:03 AM   #3
nimbus
Green Mole
 
Join Date: Dec 2003
Posts: 2
Question

I seem to have a problem.
I am trying to have the results appear in date order (latest update first). I tried your ORDER BY idea but unfortunatly, it does not change anything.

I am truly stuck. Is there another way?

Thanks in advance
nimbus is offline   Reply With Quote
Old 06-09-2004, 01:51 AM   #4
synnalagma
Green Mole
 
Join Date: Mar 2004
Posts: 22
This don't work because ordering is done on the php code and not on the database.

Try the following :
Install the mod I've submitted : Optimized Search
In queryparser.php around line 100 change
PHP Code:
$usetspider=false
to
PHP Code:
$usetspider=true
In queryparser.php around line 126

PHP Code:
$this->sql="SELECT $tengine.spider_id, SUM($tengine.weight) AS w $operatorquery FROM ".($usetspider?"$tspider, ":"")." $tengine WHERE $tengine.key_id IN (".implode(',',$this->wordsid).") $spiderquery GROUP BY $tengine.spider_id ".($operatorhaving!=""?"HAVING $operatorhaving ":"")."ORDER BY w DESC"
and change it to :

PHP Code:
$this->sql="SELECT $tengine.spider_id, SUM($tengine.weight) AS w $operatorquery FROM ".($usetspider?"$tspider, ":"")." $tengine WHERE $tengine.key_id IN (".implode(',',$this->wordsid).") $spiderquery GROUP BY $tengine.spider_id ".($operatorhaving!=""?"HAVING $operatorhaving ":"")."ORDER BY $tspider.last_modified, w DESC"
Also change around line 140

PHP Code:
$this->sql.=" END)) AS w $operatorquery FROM ".($usetspider?"$tspider, ":"")."$tengine WHERE $tengine.key_id IN (".implode(',',$this->wordsid).")  $spiderquery GROUP BY $tengine.spider_id HAVING w>0".($operatorhaving!=""?" AND $operatorhaving ":"")." ORDER BY w DESC"
to

PHP Code:
$this->sql.=" END)) AS w $operatorquery FROM ".($usetspider?"$tspider, ":"")."$tengine WHERE $tengine.key_id IN (".implode(',',$this->wordsid).")  $spiderquery GROUP BY $tengine.spider_id HAVING w>0".($operatorhaving!=""?" AND $operatorhaving ":"")." ORDER BY $tspider.last_modified, w DESC"
This should sort results by last modified and by results weight if two results have the same date.

Note I didn't tested it but it should work
synnalagma is offline   Reply With Quote
Old 06-09-2004, 02:43 AM   #5
nimbus
Green Mole
 
Join Date: Dec 2003
Posts: 2
Thanks synnalagma,

Followed your way and I have a better result. I do not have a chronological sort yet but I believe the weight plays a bit. Still trying and will keep you posted.

By the way, your Optimised search is truly optimised.
Thanks again,

Nimbus
nimbus is offline   Reply With Quote
Old 09-13-2004, 07:33 AM   #6
halley
Green Mole
 
Join Date: Sep 2004
Posts: 1
Search results ordered by update_date

Hello

I have this error do u have a idea ?
SELECT SQL_BIG_RESULT engine.spider_id, SUM((CASE WHEN engine.key_id IN (1320) THEN engine.weight *1.0 WHEN engine.key_id IN (14001,170283,49543,334503,30322,337511,298133,32081,161324,164303,10818,35 0144,341169,286488,44820,400835,64352,76436) THEN engine.weight *0.8 END)) AS w FROM engine WHERE engine.key_id IN (1320,14001,170283,49543,334503,30322,337511,298133,32081,161324,164303,108 18,350144,341169,286488,44820,400835,64352,76436) GROUP BY engine.spider_id HAVING w>0 ORDER BY spider.last_modified, w DESC Table inconnue 'spider' dans order clause
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\phpdig\libs\other_search_function.php on line 163

Thks
halley is offline   Reply With Quote
Old 09-14-2004, 02:56 AM   #7
synnalagma
Green Mole
 
Join Date: Mar 2004
Posts: 22
Verify that PHPDIG_DB_PREFIX is defined in config.php if not set it to the correct value (usually 'phpdig_').

If it's set try including config.php in class.queryparser.php by adding on top

include(PATH_TO_PHP_DIG/config.php);
(check to have correct values).

Should work
synnalagma is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Restricting search results by URL at the search form level innerfire How-to Forum 3 08-01-2005 08:36 AM
Pulling search results into existing search system. satcom How-to Forum 2 05-03-2005 10:58 AM
No most searched terms, biggest results, most 0 results, last search queries, etc. jongag1 How-to Forum 6 04-22-2005 10:43 AM
Search on search results page not working bforsyth Troubleshooting 10 08-20-2004 09:35 PM
¿Modify the label <phpdig:update_date/>? zertiko How-to Forum 2 07-25-2004 07:38 AM


All times are GMT -8. The time now is 05:18 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.