Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Improved Search Function

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #141  
Old 07-28-2005, 02:30 PM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

http://www.cs.ioc.ee/~ando/sphider/index.php

Not a completely integrated solution but defiantly a band aid or good starting point!
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #142  
Old 07-29-2005, 08:10 AM
 
Tuner Tuner is offline
 

eXpert
  
Join Date: Jan 2003
Location: Scottsdale Arizona
Posts: 245
 

Default

Definately Boomer, it seems a tad redundant unless you think the indexed DB of the Spider would run faster than X-carts search???

None the less thanks for this linke looks like a nice spider.

Thanks.

I want to use the mod that I posted or reposted on page 9 to do this.
I think it is very doable quick hack.

Upon Second thought a large portion of the search.php needs to be redone.
Learning more about coding for searching I have learned just how inefficent the methode x-cart uses.

I think Boomer has a Point with his Recommended 3rd party spider. From all my reading this is the best way to go period.

I will give this app a whirl if I can install it let you know how it goes.

Scott
__________________
\"Then again it could all be horse crap\"
by some old Guy.
4.013
Reply With Quote
  #143  
Old 07-29-2005, 04:49 PM
 
mikebo mikebo is offline
 

Advanced Member
  
Join Date: Feb 2004
Location: Ohio
Posts: 72
 

Default

I agree with Boomer, the Sphider software would be be good starting point if it could be integrated with X-Cart.

I took a look at the Sphider software, downloaded the files for it, and went to many of the sites that are using the software. It looks pretty impressive and if it could be incorporated into XCart, I would definately give it a try.
__________________
Mike
X-Cart Gold
Version 4.6.0 PHP 5.2.17
Reply With Quote
  #144  
Old 09-22-2005, 06:56 PM
 
leighj leighj is offline
 

Member
  
Join Date: Feb 2005
Posts: 15
 

Default I JUST hit this wall with a client

He was VERY frustrated with the search. (IMHO only lazy search engines only used exact phrase matching 30 years ago)

I took a look at this hack and while it was good I found an even better way.
1) It breaks apart the search critera.
2) Searches for each word individually (so brass knob will return results with 'brass knob', 'knob brass', brass and knob)
3) Then Scores the hits with the following rules.
5 if the exact search phrase appears in the title
3 if the exact search phrase appears in the description
Individual words are scored with the following method
If the FIRST word in search phrase appears in the title it gets 4 points
If the Second word in search phrase appears in the title it gets 4 - (4/number of search words).
If the third word in search phrase appears in the title it gets 4 - 2(4/number of search words).
And so on.
The same is true for the description except starting with 3.
This allows for more important words to be placed FIRST in the search.
4) Sorts the hits descending (highest score at the top).

I'm testing it now...

Additional scorings of results could be added (ie a SKU hit could be given a 7 or a price hit a 3) so searches for a product with brass that has a price of 3.50 could be searched by typing 'brass 3.50'

One failing of my code is that it destroys multiple languages. When I get it tested and cleaned up I'll post the changes.
__________________
  • X-Cart Version 4.1
  • PHP Version 4.4.x eAccelerator
  • MySQL 4.1
  • Fedora Core 1
  • Dual Xeon 2.4Ghz Hyperthreading enabled 2GB Ram
Reply With Quote
  #145  
Old 09-29-2005, 05:53 AM
 
Don L Don L is offline
 

Member
  
Join Date: Sep 2005
Posts: 27
 

Default

I'd be very interested in your solution leighj. Also, if you post what you've got now, we might be able to help with the code-polishing.
__________________
GetItCheap.com
x-cart v4.0.17

TheNewDonald.com - Internet Marketing Blog
Reply With Quote
  #146  
Old 09-29-2005, 06:09 AM
 
mikebo mikebo is offline
 

Advanced Member
  
Join Date: Feb 2004
Location: Ohio
Posts: 72
 

Default Improved Search

It looks like this topic is still a concern to others as it has been to me. I am not a programmer or developer but I was able to incorporate the Spider Search in my shop. I've used it now for about a month and have been very happy with it. It took alot of hacking and my store has been modified quite a bit, but if someone is interested in files, I'd be glad to send them to you.

The site is here: www.HilltopTreasures.com
__________________
Mike
X-Cart Gold
Version 4.6.0 PHP 5.2.17
Reply With Quote
  #147  
Old 09-29-2005, 06:17 AM
 
colonial123 colonial123 is offline
 

Senior Member
  
Join Date: Jun 2005
Location: NH
Posts: 145
 

Default Yes

If you got a better search option I could use the files. X-Carts search engine is horrible! Can you post the files?
__________________
William McCoy
Online Manager
Colonial Medical
Version 4.0.13
Reply With Quote
  #148  
Old 09-29-2005, 08:40 AM
 
leighj leighj is offline
 

Member
  
Join Date: Feb 2005
Posts: 15
 

Default Ok here's some code....

Ok here's the code
A FEW NOTES
  1. The site this works on is only one language
  2. The cool small search box still ONLY searches title,and descriptions (yeah sku would be COOL)
  3. There is no exact matching anymore. Although exact matches score higher...
  4. Score values are hard coded.
  5. Admin/provider searches are not affected
  6. I don't know if I got all the code in...
  7. Updates/Patches to X-Cart will NOT work for search.php after this.
  8. No guarantees about performance don't complain to me bout it...
  9. You break it you bought it
Look for LNJ it's around where I changed stuff
Code:
# Search for substring in some fields... $search_words=explode(" ", $data["substring"]); // This separates the string by words - LNJ if (!empty($data["by_title"])) { if($current_area == 'C' || $current_area == 'P') { //$condition[] = "IF($sql_tbl[products_lng].product IS NOT NULL AND $sql_tbl[products_lng].product != '', $sql_tbl[products_lng].product, $sql_tbl[products].product) LIKE '%".$data["substring"]."%'"; foreach($search_words as $search_word){ // Loop through adding the search words - LNJ $condition[]="$sql_tbl[products].product LIKE '%".$search_word."%'"; } } else { $condition[] = "$sql_tbl[products].product LIKE '%".$data["substring"]."%'"; } } if (!empty($data["by_shortdescr"])) { if($current_area == 'C' || $current_area == 'P') { //$condition[] = "IF($sql_tbl[products_lng].descr IS NOT NULL AND $sql_tbl[products_lng].descr != '', $sql_tbl[products_lng].descr, $sql_tbl[products].descr) LIKE '%".$data["substring"]."%'"; foreach($search_words as $search_word){ // Loop through adding the search words - LNJ $condition[]="$sql_tbl[products].descr LIKE '%".$search_word."%'"; } } else { $condition[] = "$sql_tbl[products].descr LIKE '%".$data["substring"]."%'"; } } if (!empty($data["by_fulldescr"])) { if($current_area == 'C' || $current_area == 'P') { //$condition[] = "IF($sql_tbl[products_lng].full_descr IS NOT NULL AND $sql_tbl[products_lng].full_descr != '', $sql_tbl[products_lng].full_descr, $sql_tbl[products].fulldescr) LIKE '%".$data["substring"]."%'"; foreach($search_words as $search_word){ // Loop through adding the search words - LNJ $condition[]="$sql_tbl[products].fulldescr LIKE '%".$search_word."%'"; } } else { $condition[] = "$sql_tbl[products].fulldescr LIKE '%".$data["substring"]."%'"; } }

Look for the Sort Conditions
Code:
if (!empty($data["sort_field"])) { # Sort the search results... $direction = ($data["sort_direction"] ? "DESC" : "ASC"); switch ($data["sort_field"]) { case "productcode": $sort_string = "$sql_tbl[products].productcode $direction"; break; case "title": $sort_string = "searchscore desc, $sql_tbl[products].product $direction"; // Add score to sort - LNJ break; case "orderby": $sort_string = "$sql_tbl[products_categories].orderby $direction"; break; case "quantity": $sort_string = "$sql_tbl[products].avail $direction"; break; case "price": if (!empty($active_modules["Special_Offers"]) && !empty($search_data["products"]["show_special_prices"])) { $sort_string = "x_special_price $direction, price $direction"; } else { $sort_string = "price $direction"; } break; default: $sort_string = "searchscore desc,$sql_tbl[products].product"; // Add score to sort - LNJ } } else { $sort_string = "searchscore desc,$sql_tbl[products].product"; // Add score to sort - LNJ }

Look for Generate Additional Fields String section
Code:
# # Generate additional fields string # $add_fields_string = ''; $scorestr=""; // Add score to fields - LNJ if (!empty($data["by_title"]) && count($search_words)>0) { $scorestr.="if($sql_tbl[products].product like '%". $data["substring"] ."%',5,0) + "; //Add high score for exact match - LNJ $topscore=4; // Yeah I know HARDCODED - LNJ $scoredesc=$topscore/count($search_words); //Get decrementing number for scores - LNJ foreach($search_words as $search_word){ $scorestr.="if($sql_tbl[products].product like '%". $search_word ."%',$topscore,0) + "; //add individual word score - LNJ $topscore=$topscore-$scoredesc; //Descrement individual score for word - LNJ } } if (!empty($data["by_shortdescr"]) && count($search_words)>0) { $scorestr.="if($sql_tbl[products].descr like '%". $data["substring"] ."%',3,0) + "; //Add high score for exact match - LNJ $topscore=2; $scoredesc=$topscore/count($search_words); //Get decrementing number for scores - LNJ foreach($search_words as $search_word){ $scorestr.="if($sql_tbl[products].descr like '%". $search_word ."%',$topscore,0) + "; //add individual word score - LNJ $topscore=$topscore-$scoredesc;//Descrement individual score for word - LNJ } } if (!empty($data["by_longdescr"]) && count($search_words)>0) { $scorestr.="if($sql_tbl[products].fulldescr like '%". $data["substring"] ."%',3,0) + "; //Add high score for exact match - LNJ $topscore=2; $scoredesc=$topscore/count($search_words); //Get decrementing number for scores - LNJ foreach($search_words as $search_word){ $scorestr.="if($sql_tbl[products].fulldescr like '%". $search_word ."%',$topscore,0) + "; //add individual word score - LNJ $topscore=$topscore-$scoredesc;//Descrement individual score for word - LNJ } } $add_fields[]=$scorestr . " 0 as searchscore";// Add field to query - LNJ (THIS WAS MISSING BEFORE

FINALLY if you want you can addthis to the product list template to get the score
Code:
Search Score : {$products[product].searchscore|string_format:"%.2f"}
__________________
  • X-Cart Version 4.1
  • PHP Version 4.4.x eAccelerator
  • MySQL 4.1
  • Fedora Core 1
  • Dual Xeon 2.4Ghz Hyperthreading enabled 2GB Ram
Reply With Quote
  #149  
Old 09-29-2005, 09:18 AM
 
colonial123 colonial123 is offline
 

Senior Member
  
Join Date: Jun 2005
Location: NH
Posts: 145
 

Default

It appears My search.php version is different than yours. Can you post the whole search.php code? or can you email it to me wmccoy@colonialmedical.com

I would greatly appretiate it.
__________________
William McCoy
Online Manager
Colonial Medical
Version 4.0.13
Reply With Quote
  #150  
Old 09-29-2005, 11:37 AM
 
leighj leighj is offline
 

Member
  
Join Date: Feb 2005
Posts: 15
 

Default

This is for the current 4.0.16 Version if possible upgrade to this version as I'm not sure if this will work with earlier versions...

Quote:
Originally Posted by colonial123
It appears My search.php version is different than yours. Can you post the whole search.php code? or can you email it to me wmccoy@colonialmedical.com

I would greatly appretiate it.
__________________
  • X-Cart Version 4.1
  • PHP Version 4.4.x eAccelerator
  • MySQL 4.1
  • Fedora Core 1
  • Dual Xeon 2.4Ghz Hyperthreading enabled 2GB Ram
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



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

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


All times are GMT -8. The time now is 12:21 AM.

   

 
X-Cart forums © 2001-2020