+ push @url_params,"e$i=".$q->url_param("e$i");
+
+ my $wc="*"; # swish wildcard
+ $wc="" if ($i eq ""); # don't apply wildcard on field 0
+
+ # re-write query from +/- to and/and not
+ my @param_vals = $q->param("v$i");
+ my @swish_q;
+ my ($pre,$post,$exact) = ('','','');
+ while (my $search = shift @param_vals) {
+ my $s;
+ # remove accents
+ $search = unac_string($CHARSET,$search);
+ while ($search =~ s/\s*("[^"]+")\s*/ /) {
+ $s .= "$1 ";
+ }
+ $search =~ s/^\s+//;
+ $search =~ s/\s+$//;
+
+ # filed e[nr] is exact match bitmask
+ # 1 = beginning, 2=end, 3=both
+ $pre = '"xxbxx ' if ($q->param("e$i") & 1);
+ $post = ' xxexx"' if ($q->param("e$i") & 2);
+ # add qotes on other side
+ if ($q->param("e$i")) {
+ $pre = '"' if (! $pre);
+ $post = '"' if (! $post);
+ # what about wildcards?
+ $wc = '';
+ $wc = '*' if ($q->param("e$i") & 4);
+ $exact = '_exact';
+ }
+
+ foreach (split(/\s+/,$search)) {
+ if (m/^([+-])(\S+)/) {
+ $s.= ($s) ? "and " : "";
+ $s.="not " if ($1 eq "-");
+ $s.=$2.$wc." ";
+ } elsif (m/^\s*(and|or|not)\s*$/i) {
+ $s.=$_." ";
+ # don't add * to words with less than x chars
+ } elsif (length($_) <= $MIN_WILDCARD) {
+ $s.=$_." ";
+ } else {
+ $s.=$_.$wc." ";
+ }