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 $self = ref($self) || $self;
13 $self = bless {} => $self;
15 $self->decompose($term);
17 my $newterm = join('&', $self->words);
20 $newterm = '('.$newterm.')&!('. join('|', $self->nots) . ')';
23 $log->debug("Compiled term is [$newterm]", DEBUG);
24 $newterm = OpenILS::Application::Storage::Driver::Pg->quote($newterm);
25 $log->debug("Quoted term is [$newterm]", DEBUG);
27 $self->{fts_query} = ["to_tsquery('default',$newterm)"];
28 $self->{fts_query_nots} = [];
29 $self->{fts_op} = '@@';
30 $self->{text_col} = shift;
31 $self->{fts_col} = shift;
36 sub sql_where_clause {
38 my $column = $self->fts_col;
42 for my $fts ( $self->fts_query ) {
43 push @output, join(' ', $self->fts_col, $self->{fts_op}, $fts);
44 push @ranks, "rank($column, $fts)";
46 $self->{fts_rank} = \@ranks;
48 my $phrase_match = $self->sql_exact_phrase_match();
49 return join(' AND ', @output) . $phrase_match;