3 |
use strict; |
use strict; |
4 |
use warnings; |
use warnings; |
5 |
|
|
6 |
|
our $VERSION = '0.01'; |
7 |
|
|
8 |
use Search::Estraier; |
use Search::Estraier; |
9 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
10 |
|
use Getopt::Long; |
11 |
|
use JSON; |
12 |
|
|
13 |
=head1 NAME |
=head1 NAME |
14 |
|
|
24 |
estuser => 'admin', |
estuser => 'admin', |
25 |
estpasswd => 'admin', |
estpasswd => 'admin', |
26 |
quiet => 0, |
quiet => 0, |
|
FullTextSearchQueryServer => 0, |
|
|
DbUpdateNotificationProcess => 0, |
|
27 |
}; |
}; |
28 |
|
|
29 |
|
|
30 |
=head2 run |
=head2 run_search |
31 |
|
|
32 |
Process command line options and start helper |
Process command line options and start helper |
33 |
|
|
35 |
|
|
36 |
=cut |
=cut |
37 |
|
|
38 |
sub run { |
GetOptions($c, qw/node_url=s debug+ quiet+ estuser=s estpasswd=s dbuser=s dbpasswd=s/) or die $!; |
39 |
my $self = shift; |
warn "# c: ", dump($c) if ($c->{debug}); |
40 |
GetOptions($c, qw/node_url=s debug+ quiet+ estuser=s estpasswd=s dbuser=s dbpasswd=s/) or die $!; |
|
41 |
warn "# c: ", dump($c) if ($c->{debug}); |
open(my $log, '>', '/tmp/couchdb-estraier.log'); |
42 |
if ( $c->{FullTextSearchQueryServer} ) { |
|
43 |
while ( 1 ) { |
sub run_search { |
44 |
my $database = <>; |
while ( 1 ) { |
45 |
my $query_string = <>; |
my $database = <STDIN>; |
46 |
chomp $database; |
die unless defined $database; |
47 |
chomp $query_string; |
my $query_string = <STDIN>; |
48 |
$self->search( $database, $query_string ); |
chomp $database; |
49 |
} |
chomp $query_string; |
50 |
} else { |
print $log "run_search $database\t$query_string\n"; |
51 |
while ( 1 ) { |
search( $database, $query_string ); |
52 |
my $database = <>; |
} |
53 |
my $query_string = <>; |
} |
54 |
chomp $database; |
|
55 |
chomp $query_string; |
sub run_update { |
56 |
$self->add( $database, $query_string ); |
while ( 1 ) { |
57 |
} |
my $database = <STDIN>; |
58 |
|
die unless defined $database; |
59 |
|
my $json = <STDIN>; |
60 |
|
chomp $database; |
61 |
|
chomp $json; |
62 |
|
print $log "run_update $database\t$json\n"; |
63 |
|
add( $database, from_json( $json ) ); |
64 |
} |
} |
65 |
} |
} |
66 |
|
|
67 |
|
|
68 |
=head2 add |
=head2 add |
69 |
|
|
70 |
CouchDB::Estraier->add( $database, $data ); |
CouchDB::Estraier::add( $database, $data ); |
71 |
|
|
72 |
=cut |
=cut |
73 |
|
|
74 |
sub add { |
sub add { |
75 |
my ( $self, $database, $data ) = @_; |
my ( $database, $data ) = @_; |
76 |
|
|
77 |
|
print $log "add $database ",dump( $data ),"\n"; |
78 |
|
return; |
79 |
|
|
80 |
# create and configure node |
# create and configure node |
81 |
my $node = new Search::Estraier::Node( |
my $node = new Search::Estraier::Node( |
118 |
|
|
119 |
Implementation specification: L<http://wiki.apache.org/couchdb/FullTextSearch> |
Implementation specification: L<http://wiki.apache.org/couchdb/FullTextSearch> |
120 |
|
|
121 |
CouchDB::Estraier->search( $database, $query ); |
CouchDB::Estraier::search( $database, $query ); |
122 |
|
|
123 |
=cut |
=cut |
124 |
|
|
125 |
sub search { |
sub search { |
126 |
my ( $self, $database, $query ) = @_; |
my ( $database, $query ) = @_; |
127 |
|
|
128 |
# create and configure node |
# create and configure node |
129 |
my $node = new Search::Estraier::Node( |
my $node = new Search::Estraier::Node( |