/usr/share/perl5/OpenGuides/Search/Lucy.pm is in openguides 0.76-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | package OpenGuides::Search::Lucy;
use strict;
use OpenGuides::Utils;
use Wiki::Toolkit::Search::Lucy;
=head1 NAME
OpenGuides::Search::Lucy - Run Lucy-backed text searches for OpenGuides.
=head1 DESCRIPTION
Does search stuff for OpenGuides. Distributed and installed as part of
the OpenGuides project, not intended for independent installation.
This documentation is probably only useful to OpenGuides developers.
=head1 SYNOPSIS
use OpenGuides::Config;
use OpenGuides::Search::Lucy;
my $config = OpenGuides::Config->new( file => "wiki.conf" );
my $search = OpenGuides::Search::Lucy->new( config => $config );
$search->run_text_search( search_string => "wombat defenestration" );
=head1 METHODS
=over 4
=item B<new>
my $config = OpenGuides::Config->new( file => "wiki.conf" );
my $search = OpenGuides::Search::Lucy->new( config => $config );
=cut
sub new {
my ($class, %args) = @_;
my $config = $args{config};
my $searcher = OpenGuides::Utils->make_lucy_searcher( config => $config );
my $self = {
config => $config,
searcher => $searcher,
};
bless $self, $class;
}
=item B<run_text_search>
my $config = OpenGuides::Config->new( file => "wiki.conf" );
my $search = OpenGuides::Search::Lucy->new( config => $config );
$search->run_text_search( search_string => "wombat defenestration" );
=cut
sub run_text_search {
my ( $self, %args ) = @_;
# If there are commas in the search string, we're looking at an OR search.
my $str = $args{search_string};
my $and_or = ( $str =~ /,/ ) ? "OR" : "AND";
my %finds = $self->{searcher}->search_nodes( $str, $and_or );
# Package the finds in a way that OpenGuides::Search expects.
my %results = map { $_ => { name => $_, score => $finds{$_} } }
keys %finds;
return %results;
}
=back
=cut
=head1 AUTHOR
The OpenGuides Project (openguides-dev@lists.openguides.org)
=head1 COPYRIGHT
Copyright (C) 2013 The OpenGuides Project. All Rights Reserved.
The OpenGuides distribution is free software; you can redistribute it
and/or modify it under the same terms as Perl itself.
=head1 SEE ALSO
L<OpenGuides>
=cut
1;
|