[ic] Re: fastest way to do a one-click (link) search?
interchange-users@icdevgroup.org
interchange-users@icdevgroup.org
Thu Aug 22 15:33:01 2002
Aaron Hazelton writes:
> Hi All,
>
> Im working on a catalog that will have approx. 70,000 items.
> I got MySQL working and used [query] tags in the results
> page. On the local machine, any search takes about 1 second!
>
> Anyways, I have use for a lot of 'one-click' searches via http
> links. (...scan/st=db/....). Is that the best way to do it? Is
> there any other alternative that will better use the power of
> MySQL?
>
Use op=eq and lf/ls to speed up the MySQL search.
You don't need to stick to the given scan features.
Just create your own search with the ActionMap directive.
Here is an example that hopefully don't fry everyone's brain:
#
# Custom search routine
#
ActionMap mysearch <<EOR
sub {
my $sku;
# remove surrounding whitespace
$CGI->{srchtxt} =~ s/^\s+//;
$CGI->{srchtxt} =~ s/\s+$//;
# check if the search term resembles a SKU
if ($CGI->{srchtxt} =~ /^\s*(\d\d\d)\.?(\d\d)\.?(\d[\dA-Za-z]?)\s*$/) {
$sku = "$1.$2.$3";
$CGI->{mv_todo} = 'go';
if ($CGI->{skip_frameset} == 1) {
$CGI->{mv_nextpage} = 'bestellung/content';
} else {
$CGI->{mv_nextpage} = 'bestellung/index';
}
$Values->{b_number1} = $CGI->{b_number1} = $sku;
return 1;
}
# check if we should go to premium entry page
if (grep {$_ eq $CGI->{srchtxt}} (split (/\s*,\s*/,
$Variable->{SEARCH_PREMIUM_MATCH}))) {
$CGI->{mv_todo} = 'go';
if ($CGI->{skip_frameset}) {
$CGI->{mv_nextpage} = 'freundschaftswerbung/content';
} else {
$CGI->{mv_nextpage} = 'freundschaftswerbung/index';
}
return 1;
}
unless ($CGI->{skip_frameset}) {
$CGI->{mv_nextpage} = 'komfortsuche/index';
return 1;
}
$CGI->{mv_todo} = 'search';
$CGI->{mv_nextpage} = 'overview';
$CGI->{mv_coordinate} = 1;
$CGI->{mv_searchtype} = 'db';
$CGI->{mv_matchlimit} = 4;
$CGI->{mv_sort_field} = 'cat';
# exclude premiums, merchandising etc.
$CGI->{mv_search_field} = 'cat';
$CGI->{mv_column_op} = 'rn';
$CGI->{mv_searchspec} = '9\d-';
# exclude disabled products
$CGI->{mv_search_field} .= "\0show_pic";
$CGI->{mv_searchspec} .= "\0" . '1';
$CGI->{mv_column_op} .= "\0eq";
# exclude products only available in other countries
$CGI->{mv_like_field} = 'countries';
$CGI->{mv_like_spec} = "%$Variable->{TLD}";
# search overview on user's request
if ($CGI->{srchtxt}) {
my $fix;
# we need to mangle it ?
if ($fix = $Db{searchfix}->field($CGI->{srchtxt},'fix')) {
$CGI->{srchtxt} = $fix;
}
$CGI->{mv_like_field} .= "\0overview";
$CGI->{mv_like_spec} .= "\0%$CGI->{srchtxt}";
}
# search for searchtoken on user's request
if ($CGI->{srchkey}) {
$CGI->{mv_like_field} .= "\0komfort_suchfunktion";
$CGI->{mv_like_spec} .= "\0%$CGI->{srchkey}";
}
$Tag->update('process');
return 1;
}
EOR
Ciao
Racke
--
Prolific Interchange Consulting (Excellent German Quality !).
Take a look at Materialboerse (http://www.materialboerse.de/), WITT
(http://www.witt-weiden.de/), Boxmover (http://shop.boxmover.ch/) or
Passionshop (http://www.passionshop.com/racke). Need a shop ? Contact us.