Working on a fix to speed up title and author searches
This commit is contained in:
parent
51ee67d237
commit
132835283a
1 changed files with 30 additions and 38 deletions
68
C4/Search.pm
68
C4/Search.pm
|
@ -462,11 +462,10 @@ sub CatSearch {
|
||||||
my $count=@key;
|
my $count=@key;
|
||||||
my $i=1;
|
my $i=1;
|
||||||
$query="select *,biblio.author,biblio.biblionumber from
|
$query="select *,biblio.author,biblio.biblionumber from
|
||||||
biblioitems,biblio
|
biblio
|
||||||
left join additionalauthors
|
left join additionalauthors
|
||||||
on additionalauthors.biblionumber =biblio.biblionumber
|
on additionalauthors.biblionumber =biblio.biblionumber
|
||||||
where biblioitems.biblionumber=biblio.biblionumber
|
where
|
||||||
and
|
|
||||||
((biblio.author like '$key[0]%' or biblio.author like '% $key[0]%' or
|
((biblio.author like '$key[0]%' or biblio.author like '% $key[0]%' or
|
||||||
additionalauthors.author like '$key[0]%' or additionalauthors.author
|
additionalauthors.author like '$key[0]%' or additionalauthors.author
|
||||||
like '% $key[0]%'
|
like '% $key[0]%'
|
||||||
|
@ -504,22 +503,7 @@ sub CatSearch {
|
||||||
#$query=$query. " and (title like '%$search->{'title'}%'
|
#$query=$query. " and (title like '%$search->{'title'}%'
|
||||||
#or seriestitle like '%$search->{'title'}%')";
|
#or seriestitle like '%$search->{'title'}%')";
|
||||||
}
|
}
|
||||||
if ($search->{'class'} ne ''){
|
|
||||||
my @temp=split(/\|/,$search->{'class'});
|
|
||||||
my $count=@temp;
|
|
||||||
$query.= "and ( itemtype='$temp[0]'";
|
|
||||||
for (my $i=1;$i<$count;$i++){
|
|
||||||
$query.=" or itemtype='$temp[$i]'";
|
|
||||||
}
|
|
||||||
$query.=") ";
|
|
||||||
}
|
|
||||||
if ($search->{'dewey'} ne ''){
|
|
||||||
$query.=" and dewey='$search->{'dewey'}' ";
|
|
||||||
}
|
|
||||||
if ($search->{'illustrator'} ne ''){
|
|
||||||
$query.=" and illus like '%".$search->{'illustrator'}."%' ";
|
|
||||||
}
|
|
||||||
|
|
||||||
$query.=" group by biblio.biblionumber";
|
$query.=" group by biblio.biblionumber";
|
||||||
} else {
|
} else {
|
||||||
if ($search->{'title'} ne '') {
|
if ($search->{'title'} ne '') {
|
||||||
|
@ -539,11 +523,10 @@ sub CatSearch {
|
||||||
my @key=split(' ',$search->{'title'});
|
my @key=split(' ',$search->{'title'});
|
||||||
my $count=@key;
|
my $count=@key;
|
||||||
my $i=1;
|
my $i=1;
|
||||||
$query="select * from biblio,biblioitems
|
$query="select * from biblio
|
||||||
left join bibliosubtitle on
|
left join bibliosubtitle on
|
||||||
biblio.biblionumber=bibliosubtitle.biblionumber
|
biblio.biblionumber=bibliosubtitle.biblionumber
|
||||||
where
|
where
|
||||||
biblioitems.biblionumber=biblio.biblionumber and
|
|
||||||
(((title like '$key[0]%' or title like '% $key[0]%' or title like '% $key[0]')";
|
(((title like '$key[0]%' or title like '% $key[0]%' or title like '% $key[0]')";
|
||||||
while ($i<$count){
|
while ($i<$count){
|
||||||
$query=$query." and (title like '$key[$i]%' or title like '% $key[$i]%' or title like '% $key[$i]')";
|
$query=$query." and (title like '$key[$i]%' or title like '% $key[$i]%' or title like '% $key[$i]')";
|
||||||
|
@ -562,21 +545,6 @@ sub CatSearch {
|
||||||
$query.=" and (unititle like '$key[$i]%' or unititle like '% $key[$i]%')";
|
$query.=" and (unititle like '$key[$i]%' or unititle like '% $key[$i]%')";
|
||||||
}
|
}
|
||||||
$query=$query."))";
|
$query=$query."))";
|
||||||
if ($search->{'class'} ne ''){
|
|
||||||
my @temp=split(/\|/,$search->{'class'});
|
|
||||||
my $count=@temp;
|
|
||||||
$query.= " and ( itemtype='$temp[0]'";
|
|
||||||
for (my $i=1;$i<$count;$i++){
|
|
||||||
$query.=" or itemtype='$temp[$i]'";
|
|
||||||
}
|
|
||||||
$query.=")";
|
|
||||||
}
|
|
||||||
if ($search->{'dewey'} ne ''){
|
|
||||||
$query.=" and dewey='$search->{'dewey'}' ";
|
|
||||||
}
|
|
||||||
if ($search->{'illustrator'} ne ''){
|
|
||||||
$query.=" and illus like '%".$search->{'illustrator'}."%' ";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} elsif ($search->{'class'} ne ''){
|
} elsif ($search->{'class'} ne ''){
|
||||||
$query="select * from biblioitems,biblio where biblio.biblionumber=biblioitems.biblionumber";
|
$query="select * from biblioitems,biblio where biblio.biblionumber=biblioitems.biblionumber";
|
||||||
|
@ -680,13 +648,36 @@ my $count=1;
|
||||||
my $i=0;
|
my $i=0;
|
||||||
my $limit= $num+$offset;
|
my $limit= $num+$offset;
|
||||||
while (my $data=$sth->fetchrow_hashref){
|
while (my $data=$sth->fetchrow_hashref){
|
||||||
my $sti=$dbh->prepare("select dewey,subclass from biblioitems where biblionumber=$data->{'biblionumber'}");
|
my $query="select dewey,subclass from biblioitems where biblionumber=$data->{'biblionumber'}";
|
||||||
|
if ($search->{'class'} ne ''){
|
||||||
|
my @temp=split(/\|/,$search->{'class'});
|
||||||
|
my $count=@temp;
|
||||||
|
$query.= " and ( itemtype='$temp[0]'";
|
||||||
|
for (my $i=1;$i<$count;$i++){
|
||||||
|
$query.=" or itemtype='$temp[$i]'";
|
||||||
|
}
|
||||||
|
$query.=")";
|
||||||
|
}
|
||||||
|
if ($search->{'dewey'} ne ''){
|
||||||
|
$query.=" and dewey='$search->{'dewey'}' ";
|
||||||
|
}
|
||||||
|
if ($search->{'illustrator'} ne ''){
|
||||||
|
$query.=" and illus like '%".$search->{'illustrator'}."%' ";
|
||||||
|
}
|
||||||
|
#print $query;
|
||||||
|
my $sti=$dbh->prepare($query);
|
||||||
$sti->execute;
|
$sti->execute;
|
||||||
my ($dewey, $subclass) = $sti->fetchrow;
|
my $dewey;
|
||||||
|
my $subclass;
|
||||||
|
my $true=0;
|
||||||
|
if (($dewey, $subclass) = $sti->fetchrow){
|
||||||
|
$true=1;
|
||||||
|
}
|
||||||
$dewey=~s/\.*0*$//;
|
$dewey=~s/\.*0*$//;
|
||||||
($dewey == 0) && ($dewey='');
|
($dewey == 0) && ($dewey='');
|
||||||
($dewey) && ($dewey.=" $subclass");
|
($dewey) && ($dewey.=" $subclass");
|
||||||
$sti->finish;
|
$sti->finish;
|
||||||
|
if ($true == 1){
|
||||||
if ($count > $offset && $count <= $limit){
|
if ($count > $offset && $count <= $limit){
|
||||||
if ($type ne 'subject' && $type ne 'precise'){
|
if ($type ne 'subject' && $type ne 'precise'){
|
||||||
$results[$i]="$data->{'author'}\t$data->{'title'}\t$data->{'biblionumber'}\t$data->{'copyrightdate'}\t$dewey\t$data->{'illus'}";
|
$results[$i]="$data->{'author'}\t$data->{'title'}\t$data->{'biblionumber'}\t$data->{'copyrightdate'}\t$dewey\t$data->{'illus'}";
|
||||||
|
@ -698,6 +689,7 @@ while (my $data=$sth->fetchrow_hashref){
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$count++;
|
$count++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$sth->finish;
|
$sth->finish;
|
||||||
#if ($type ne 'precise'){
|
#if ($type ne 'precise'){
|
||||||
|
|
Loading…
Reference in a new issue