+ @and = ( qq{ rad_ustanova.sifra = ? } );
+ @exec = ( 130 ); # FIXME ustanova
+
+ sub parse_fti {
+ my $query = shift;
+ warn "## parse_fti [$query]";
+ my $fti;
+ if ( $query =~ s/^(fti_.+):// ) {
+ $fti = $1;
+ } else {
+ warn "INVALID QUERY no fti_xxx: [$query]";
+ }
+
+ my $tsquery = join(' & ', split(/\s+/,$query) );
+
+ my @or;
+ foreach my $f ( split(/,/,$fti) ) {
+ push @or, "$f @@ to_tsquery(?)";
+ push @exec, $tsquery;
+ };
+ push @and, "( " . join(" or ", @or) . ")";
+ }
+
+ if ( $query =~ / AND / ) {
+ foreach my $and ( split(/ AND /, $query) ) {
+ parse_fti $and;
+ }
+ } elsif ( $query =~ m/fti_.+:/ ) {
+ parse_fti $query;
+ } else { # no " AND " in query
+ my $tsquery = join(' & ', split(/\s+/,$query) );
+ push @and, "( fti_au @@ to_tsquery(?) or fti_pr @@ to_tsquery(?) )";
+ push @exec, $tsquery, $tsquery;
+ }