/[Grep]/lib/Grep/Search.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/Grep/Search.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 60 by dpavlin, Wed Feb 21 19:31:26 2007 UTC revision 64 by dpavlin, Wed Feb 21 20:22:07 2007 UTC
# Line 52  sub writer { Line 52  sub writer {
52    
53  =head2 add  =head2 add
54    
55    Grep::Search->add( $record );    Grep::Search->add( $record, $owner_id );
56    
57  =cut  =cut
58    
# Line 60  sub add { Line 60  sub add {
60          my $self = shift;          my $self = shift;
61    
62          my $i = shift or die "no record to add";          my $i = shift or die "no record to add";
63            my $uid = shift;
64    
65          die "record not Jifty::Record but ", ref $i unless ($i->isa('Jifty::Record'));          die "record not Jifty::Record but ", ref $i unless ($i->isa('Jifty::Record'));
66    
# Line 110  sub add { Line 111  sub add {
111                  }                  }
112          }          }
113    
114            # add _owner_id to speed up filtering of search results
115            $uid ||= Jifty->web->current_user->id;
116            $doc->add(Lucene::Document::Field->Keyword( '_owner_id', $uid ));
117    
118          $self->writer->addDocument($doc);          $self->writer->addDocument($doc);
119    
120          Jifty->log->debug("added ", $i->id, " to index");          Jifty->log->debug("added ", $i->id, " for user $uid to index");
121  }  }
122    
123  =head2  =head2
# Line 130  sub collection { Line 135  sub collection {
135    
136          my $searcher = new Lucene::Search::IndexSearcher($self->store);          my $searcher = new Lucene::Search::IndexSearcher($self->store);
137          my $parser = new Lucene::QueryParser("content", $self->analyzer);          my $parser = new Lucene::QueryParser("content", $self->analyzer);
138          my $query = $parser->parse( $q );  
139            my $full_q = "($q) AND _owner_id:" . Jifty->web->current_user->id;
140    
141            my $query = $parser->parse( $full_q );
142    
143          Jifty->log->debug("searching for '$q' using ", $query->toString);          Jifty->log->debug("searching for '$q' using ", $query->toString);
144    

Legend:
Removed from v.60  
changed lines
  Added in v.64

  ViewVC Help
Powered by ViewVC 1.1.26