If we have no search terms, we shouldn't kick off a search. Accordingly,
track whether we have, in fact, any type + value combos where value is
not an empty string, or a non-empty original query, and return
immediately if we have nothing to search.
Compare the results of the following opensrf call before and after:
request open-ils.search open-ils.search.biblio.multiclass.query {}
"title: "
Signed-off-by: Dan Scott <dscott@laurentian.ca>
my $modifier_list_re = qr/(?:site|dir|sort|lang|available|preflib)/;
my $tmp_value = '';
+ my $nonempty_search = 0; # prevent entirely empty queries
while ($query =~ s/$simple_class_re//so) {
my $qpart = $1;
$tmp_value = '';
}
- next unless $type and $value;
+ next unless $type;
$value =~ s/^\s*//og;
$value =~ s/\s*$//og;
+
+ next unless $value;
+
$type = 'sort_dir' if $type eq 'dir';
if($type eq 'site') {
$search->{$type}->{term} =
($search->{$type}->{term}) ? $search->{$type}->{term} . " $value" : $value;
}
+ $nonempty_search = 1;
}
$query .= " $tmp_value";
$search->{$type} = {} unless $search->{$type};
$search->{$type}->{term} =
($search->{$type}->{term}) ? $search->{$type}->{term} . " $query" : $query;
+ $nonempty_search = 1;
}
+
+ return unless $nonempty_search;
+
my $real_search = $arghash->{searches} = { $type => { term => $orig_query } };
# capture the original limit because the search method alters the limit internally