Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
467 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package OpenGuides::Search::Lucy; | ||
use strict; | ||
|
||
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 = Wiki::Toolkit::Search::Lucy->new( | ||
path => $config->indexing_directory ); | ||
|
||
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package OpenGuides::Search::Lucy; | ||
use strict; | ||
|
||
=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" ); | ||
OpenGuides::Search::Lucy->run_text_search( | ||
config => $config, | ||
search_string => "wombat defenestration", | ||
); | ||
|
||
=head1 METHODS | ||
|
||
=over 4 | ||
|
||
=item B<run_text_search> | ||
|
||
my $config = OpenGuides::Config->new( file => "wiki.conf" ); | ||
OpenGuides::Search::Lucy->run_text_search( | ||
config => $config, | ||
search_string => "wombat defenestration", | ||
); | ||
|
||
=cut | ||
|
||
sub run_text_search { | ||
} | ||
|
||
=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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.