1 { # Every driver needs to provide a 'compile()' method to OpenILS::Application::Storage::FTS.
2 # If that driver wants to support FTI, that is...
3 #-------------------------------------------------------------------------------
4 package OpenILS::Application::Storage::FTS;
5 use OpenSRF::Utils::Logger qw/:level/;
6 my $log = 'OpenSRF::Utils::Logger';
12 $log->debug("Raw term: $term",DEBUG);
17 $self = ref($self) || $self;
18 $self = bless {} => $self;
21 $self->decompose($term);
23 my $newterm = join('&', $self->words);
26 $newterm = '('.$newterm.')&!('. join('|', $self->nots) . ')';
29 $log->debug("Compiled term is [$newterm]", DEBUG);
30 $newterm = OpenILS::Application::Storage::Driver::Pg->quote($newterm);
31 $log->debug("Quoted term is [$newterm]", DEBUG);
33 $self->{fts_query} = ["to_tsquery('default',$newterm)"];
34 $self->{fts_query_nots} = [];
35 $self->{fts_op} = '@@';
36 $self->{text_col} = shift;
37 $self->{fts_col} = shift;
42 sub sql_where_clause {
44 my $column = $self->fts_col;
48 for my $fts ( $self->fts_query ) {
49 push @output, join(' ', $self->fts_col, $self->{fts_op}, $fts);
50 push @ranks, "rank($column, $fts)";
52 $self->{fts_rank} = \@ranks;
54 my $phrase_match = $self->sql_exact_phrase_match();
55 return join(' AND ', @output) . $phrase_match;