+ |;
+
+ my $swish = SWISH::API->new( "$dir/../var/swish/$database" );
+ $swish->abort_last_error if $swish->Error;
+
+ my @search = ();
+ if ( $search =~ m{(=|"|AND|OR)} ) {
+ push @search, $search;
+ } elsif ( my $op = param('attr_operator') ) {
+ my $attr = param('attr');
+ my $v = $search;
+ $v =~ s/^\s+//;
+ warn "-- v: $v\n";
+ sub rewrite {
+ my ( $whitespace, $v ) = @_;
+ warn "## filter $op $whitespace $v\n";
+ my $template = $op;
+ $template =~ s{Q}{$v};
+ $whitespace = " AND " if $whitespace;
+
+ return
+ $whitespace .
+ $attr . '="' . $template . '"';
+ ;
+ };
+ if ( $op =~ m{\s} ) {
+ my $template = $op;
+ $template =~ s{Q}{$v};
+ $v = $attr . '="' . $template . '"';
+ } else {
+ $v =~ s{(\s*)(\S+)}{rewrite($1,$2)}ge;
+ }
+
+ push @search, $v;
+
+ my @only_input = param('only_input');
+ push @search, '((' . join(') OR (', map { "input=\"$_\"" } @only_input) . '))' if @only_input;
+ } else {
+ push @search, "all=\"$search\"";
+ }
+
+ my $q = '(' . join(') AND (', @search) . ')';
+ $q =~ s{\(\((.+)\)\)}{($1)};
+ warn "# query: $q\n";
+ my $swish_results = $swish->query( $q );
+
+ dump_yaml( 'swish_results', $swish_results );
- my $node = Search::Estraier::Node->new(
- url => $config->{hyperestraier}->{masterurl} . '/node/' . $database,
- croak_on_error => 1,
- );
-
- my $cond = Search::Estraier::Condition->new;
- $cond->set_phrase( $search );
- my $nres = $node->search( $cond, 0 );
-
- if ( ! $nres ) {
- my $no_results = "No results for search '%s'";
- printf qq|
$no_results|, $search;
+ my $pager = Data::Page->new;
+ $pager->$_( param($_) ) foreach ( qw/entries_per_page current_page/ );
+ $pager->total_entries( $swish_results->hits );
+
+ dump_yaml( 'pager', $pager );
+
+ $swish_results->seek_result( $pager->first - 1 );
+
+ if ( ! $pager->total_entries ) {
+ my $no_results = 'No results for search
%s';
+ $no_results = $swish->error_string . '
%s' if $swish->error;
+ printf qq|
$no_results
\n\n|, $q;
} else {
- print qq|
|;
+ print qq|\n\n|;
+
+ print qq|\n\n| if $pager_html;
}
print qq|
|;
+
+ dump_yaml( 'pager', $pager );
+
}
-dump_yaml( $estraier );
-dump_yaml( $db );
+print search_form;
+
+dump_yaml( "config databases $database", $db );
+dump_yaml( 'html_markup_skip', $html_markup_skip );
print end_html;