View | Details | Raw Unified | Return to bug 16588
Collapse All | Expand All

(-)a/C4/AuthoritiesMarc.pm (-2 / +2 lines)
Lines 353-359 sub CountUsage { Link Here
353
        $query= "an:".$authid;
353
        $query= "an:".$authid;
354
        # Should really be replaced with a real count call, this is a
354
        # Should really be replaced with a real count call, this is a
355
        # bad way.
355
        # bad way.
356
        my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
356
        my $searcher = Koha::SearchEngine::Search->new({index => Koha::SearchEngine::BIBLIOS_INDEX});
357
        my ($err,$res,$result) = $searcher->simple_search_compat($query,0,1);
357
        my ($err,$res,$result) = $searcher->simple_search_compat($query,0,1);
358
        if ($err) {
358
        if ($err) {
359
            warn "Error: $err from search $query";
359
            warn "Error: $err from search $query";
Lines 827-833 sub FindDuplicateAuthority { Link Here
827
            $_->[1]=~s/$filtervalues/ /g; $query.= " $op he:\"".$_->[1]."\"" if ($_->[0]=~/[A-z]/);
827
            $_->[1]=~s/$filtervalues/ /g; $query.= " $op he:\"".$_->[1]."\"" if ($_->[0]=~/[A-z]/);
828
        }
828
        }
829
    }
829
    }
830
    my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::AUTHORITIES_INDEX});
830
    my $searcher = Koha::SearchEngine::Search->new({index => Koha::SearchEngine::AUTHORITIES_INDEX});
831
    my ($error, $results, $total_hits) = $searcher->simple_search_compat( $query, 0, 1 );
831
    my ($error, $results, $total_hits) = $searcher->simple_search_compat( $query, 0, 1 );
832
    # there is at least 1 result => return the 1st one
832
    # there is at least 1 result => return the 1st one
833
    if (!defined $error && @{$results} ) {
833
    if (!defined $error && @{$results} ) {
(-)a/C4/Biblio.pm (-2 / +2 lines)
Lines 2922-2929 sub ModZebra { Link Here
2922
        my $indexer = Koha::ElasticSearch::Indexer->new(
2922
        my $indexer = Koha::ElasticSearch::Indexer->new(
2923
            {
2923
            {
2924
                index => $server eq 'biblioserver'
2924
                index => $server eq 'biblioserver'
2925
                ? $Koha::SearchEngine::BIBLIOS_INDEX
2925
                ? Koha::SearchEngine::BIBLIOS_INDEX
2926
                : $Koha::SearchEngine::AUTHORITIES_INDEX
2926
                : Koha::SearchEngine::AUTHORITIES_INDEX
2927
            }
2927
            }
2928
        );
2928
        );
2929
        if ( $op eq 'specialUpdate' ) {
2929
        if ( $op eq 'specialUpdate' ) {
(-)a/C4/Items.pm (-1 / +1 lines)
Lines 2514-2520 sub GetAnalyticsCount { Link Here
2514
    ### ZOOM search here
2514
    ### ZOOM search here
2515
    my $query;
2515
    my $query;
2516
    $query= "hi=".$itemnumber;
2516
    $query= "hi=".$itemnumber;
2517
    my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
2517
    my $searcher = Koha::SearchEngine::Search->new({index => Koha::SearchEngine::BIBLIOS_INDEX});
2518
    my ($err,$res,$result) = $searcher->simple_search_compat($query,0,10);
2518
    my ($err,$res,$result) = $searcher->simple_search_compat($query,0,10);
2519
    return ($result);
2519
    return ($result);
2520
}
2520
}
(-)a/C4/Matcher.pm (-1 / +1 lines)
Lines 656-662 sub get_matches { Link Here
656
                    #NOTE: double-quote the values so you don't get a "Embedded truncation not supported" error when a term has a ? in it.
656
                    #NOTE: double-quote the values so you don't get a "Embedded truncation not supported" error when a term has a ? in it.
657
            }
657
            }
658
658
659
            my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
659
            my $searcher = Koha::SearchEngine::Search->new({index => Koha::SearchEngine::BIBLIOS_INDEX});
660
            ( $error, $searchresults, $total_hits ) =
660
            ( $error, $searchresults, $total_hits ) =
661
              $searcher->simple_search_compat( $query, 0, $max_matches );
661
              $searcher->simple_search_compat( $query, 0, $max_matches );
662
        }
662
        }
(-)a/C4/XISBN.pm (-1 / +1 lines)
Lines 66-72 sub _get_biblio_from_xisbn { Link Here
66
    my $xisbn = shift;
66
    my $xisbn = shift;
67
    my $dbh = C4::Context->dbh;
67
    my $dbh = C4::Context->dbh;
68
68
69
    my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
69
    my $searcher = Koha::SearchEngine::Search->new({index => Koha::SearchEngine::BIBLIOS_INDEX});
70
    my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat( "nb=$xisbn", 0, 1 );
70
    my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat( "nb=$xisbn", 0, 1 );
71
    return unless ( !$errors && scalar @$results );
71
    return unless ( !$errors && scalar @$results );
72
72
(-)a/Koha/ElasticSearch.pm (-3 / +4 lines)
Lines 26-32 use Koha::Database; Link Here
26
use Carp;
26
use Carp;
27
use JSON;
27
use JSON;
28
use Modern::Perl;
28
use Modern::Perl;
29
use Readonly;
30
29
31
use Data::Dumper;    # TODO remove
30
use Data::Dumper;    # TODO remove
32
31
Lines 34-41 __PACKAGE__->mk_ro_accessors(qw( index )); Link Here
34
__PACKAGE__->mk_accessors(qw( sort_fields ));
33
__PACKAGE__->mk_accessors(qw( sort_fields ));
35
34
36
# Constants to refer to the standard index names
35
# Constants to refer to the standard index names
37
Readonly our $BIBLIOS_INDEX     => 'biblios';
36
use constant {
38
Readonly our $AUTHORITIES_INDEX => 'authorities';
37
    BIBLIOS_INDEX     => 'biblios',
38
    AUTHORITIES_INDEX => 'authorities',
39
};
39
40
40
=head1 NAME
41
=head1 NAME
41
42
(-)a/Koha/SearchEngine.pm (-3 / +4 lines)
Lines 19-25 package Koha::SearchEngine; Link Here
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
20
21
use Modern::Perl;
21
use Modern::Perl;
22
use Readonly;
23
22
24
=head1 NAME
23
=head1 NAME
25
24
Lines 42-46 indicate that you want to be working with the authorities index. Link Here
42
# Search engine implementations should compare against these to determine
41
# Search engine implementations should compare against these to determine
43
# what bit of storage is being requested. They will be sensible strings so
42
# what bit of storage is being requested. They will be sensible strings so
44
# may be used for, e.g., directory names.
43
# may be used for, e.g., directory names.
45
Readonly our $BIBLIOS_INDEX     => 'biblios';
44
use constant {
46
Readonly our $AUTHORITIES_INDEX => 'authorities';
45
    BIBLIOS_INDEX     => 'biblios',
46
    AUTHORITIES_INDEX => 'authorities',
47
};
(-)a/Koha/SearchEngine/QueryBuilder.pm (-1 / +1 lines)
Lines 33-39 and just get whatever querybuilder you need. Link Here
33
=head1 SYNOPSIS
33
=head1 SYNOPSIS
34
34
35
    use Koha::SearchEngine::QueryBuilder;
35
    use Koha::SearchEngine::QueryBuilder;
36
    my $qb = Koha::SearchEngine::QueryBuilder->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
36
    my $qb = Koha::SearchEngine::QueryBuilder->new({index => Koha::SearchEngine::BIBLIOS_INDEX});
37
37
38
=head1 METHODS
38
=head1 METHODS
39
39
(-)a/acqui/neworderbiblio.pl (-2 / +2 lines)
Lines 102-109 my @operands = $query; Link Here
102
my $QParser;
102
my $QParser;
103
$QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
103
$QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
104
my $builtquery;
104
my $builtquery;
105
my $builder  = Koha::SearchEngine::QueryBuilder->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
105
my $builder  = Koha::SearchEngine::QueryBuilder->new({index => Koha::SearchEngine::BIBLIOS_INDEX});
106
my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
106
my $searcher = Koha::SearchEngine::Search->new({index => Koha::SearchEngine::BIBLIOS_INDEX});
107
if ($QParser) {
107
if ($QParser) {
108
    $builtquery = $query;
108
    $builtquery = $query;
109
} else {
109
} else {
(-)a/authorities/authorities-home.pl (-2 / +2 lines)
Lines 80-88 if ( $op eq "do_search" ) { Link Here
80
    my $resultsperpage = $query->param('resultsperpage') || 20;
80
    my $resultsperpage = $query->param('resultsperpage') || 20;
81
81
82
    my $builder = Koha::SearchEngine::QueryBuilder->new(
82
    my $builder = Koha::SearchEngine::QueryBuilder->new(
83
        { index => $Koha::SearchEngine::AUTHORITIES_INDEX } );
83
        { index => Koha::SearchEngine::AUTHORITIES_INDEX } );
84
    my $searcher = Koha::SearchEngine::Search->new(
84
    my $searcher = Koha::SearchEngine::Search->new(
85
        { index => $Koha::SearchEngine::AUTHORITIES_INDEX } );
85
        { index => Koha::SearchEngine::AUTHORITIES_INDEX } );
86
    my $search_query = $builder->build_authorities_query_compat(
86
    my $search_query = $builder->build_authorities_query_compat(
87
        [$marclist], [$and_or], [$excluding], [$operator],
87
        [$marclist], [$and_or], [$excluding], [$operator],
88
        [$value], $authtypecode, $orderby
88
        [$value], $authtypecode, $orderby
(-)a/authorities/authorities-list.pl (-1 / +1 lines)
Lines 26-32 foreach my $authority (@$dataauthorities){ Link Here
26
  my $query;
26
  my $query;
27
  $query= "an=".$authority->{'authid'};
27
  $query= "an=".$authority->{'authid'};
28
  # search for biblios mapped
28
  # search for biblios mapped
29
  my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
29
  my $searcher = Koha::SearchEngine::Search->new({index => Koha::SearchEngine::BIBLIOS_INDEX});
30
  my ($err,undef,$used) = $searcher->simple_search_compat($query,0,1);
30
  my ($err,undef,$used) = $searcher->simple_search_compat($query,0,1);
31
  if (defined $err) {
31
  if (defined $err) {
32
      $used = 0;
32
      $used = 0;
(-)a/catalogue/search.pl (-2 / +2 lines)
Lines 476-484 my $expanded_facet = $params->{'expand'}; Link Here
476
my ( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type);
476
my ( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type);
477
477
478
my $builder = Koha::SearchEngine::QueryBuilder->new(
478
my $builder = Koha::SearchEngine::QueryBuilder->new(
479
    { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
479
    { index => Koha::SearchEngine::BIBLIOS_INDEX } );
480
my $searcher = Koha::SearchEngine::Search->new(
480
my $searcher = Koha::SearchEngine::Search->new(
481
    { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
481
    { index => Koha::SearchEngine::BIBLIOS_INDEX } );
482
482
483
## I. BUILD THE QUERY
483
## I. BUILD THE QUERY
484
(
484
(
(-)a/cataloguing/addbooks.pl (-2 / +2 lines)
Lines 78-86 if ($query) { Link Here
78
    $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
78
    $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
79
    my $builtquery;
79
    my $builtquery;
80
    my $builder = Koha::SearchEngine::QueryBuilder->new(
80
    my $builder = Koha::SearchEngine::QueryBuilder->new(
81
        { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
81
        { index => Koha::SearchEngine::BIBLIOS_INDEX } );
82
    my $searcher = Koha::SearchEngine::Search->new(
82
    my $searcher = Koha::SearchEngine::Search->new(
83
        { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
83
        { index => Koha::SearchEngine::BIBLIOS_INDEX } );
84
    if ($QParser) {
84
    if ($QParser) {
85
        $builtquery = $query;
85
        $builtquery = $query;
86
    } else {
86
    } else {
(-)a/cataloguing/value_builder/marc21_linking_section.pl (-1 / +1 lines)
Lines 183-189 my $launcher = sub { Link Here
183
            $op = 'and';
183
            $op = 'and';
184
        }
184
        }
185
        my $searcher = Koha::SearchEngine::Search->new(
185
        my $searcher = Koha::SearchEngine::Search->new(
186
            { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
186
            { index => Koha::SearchEngine::BIBLIOS_INDEX } );
187
        $search = 'kw:' . $search . " $op mc-itemtype:" . $itype if $itype;
187
        $search = 'kw:' . $search . " $op mc-itemtype:" . $itype if $itype;
188
        my ( $errors, $results, $total_hits ) =
188
        my ( $errors, $results, $total_hits ) =
189
          $searcher->simple_search_compat( $search,
189
          $searcher->simple_search_compat( $search,
(-)a/cataloguing/value_builder/unimarc_field_4XX.pl (-1 / +1 lines)
Lines 369-375 sub plugin { Link Here
369
            $op = 'and';
369
            $op = 'and';
370
        }
370
        }
371
        $search = 'kw:'.$search." $op mc-itemtype:".$itype if $itype;
371
        $search = 'kw:'.$search." $op mc-itemtype:".$itype if $itype;
372
        my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
372
        my $searcher = Koha::SearchEngine::Search->new({index => Koha::SearchEngine::BIBLIOS_INDEX});
373
        my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat($search, $startfrom * $resultsperpage, $resultsperpage );
373
        my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat($search, $startfrom * $resultsperpage, $resultsperpage );
374
        if (defined $errors ) {
374
        if (defined $errors ) {
375
            $results = [];
375
            $results = [];
(-)a/circ/circulation.pl (-1 / +1 lines)
Lines 348-354 if (@$barcodes) { Link Here
348
    {
348
    {
349
     $template_params->{FALLBACK} = 1;
349
     $template_params->{FALLBACK} = 1;
350
350
351
        my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
351
        my $searcher = Koha::SearchEngine::Search->new({index => Koha::SearchEngine::BIBLIOS_INDEX});
352
        my $query = "kw=" . $barcode;
352
        my $query = "kw=" . $barcode;
353
        my ( $searcherror, $results, $total_hits ) = $searcher->simple_search_compat($query, 0, 10);
353
        my ( $searcherror, $results, $total_hits ) = $searcher->simple_search_compat($query, 0, 10);
354
354
(-)a/misc/migration_tools/bulkmarcimport.pl (-2 / +2 lines)
Lines 223-230 my $searcher = Koha::SearchEngine::Search->new( Link Here
223
    {
223
    {
224
        index => (
224
        index => (
225
              $authorities
225
              $authorities
226
            ? $Koha::SearchEngine::AUTHORITIES_INDEX
226
            ? Koha::SearchEngine::AUTHORITIES_INDEX
227
            : $Koha::SearchEngine::BIBLIOS_INDEX
227
            : Koha::SearchEngine::BIBLIOS_INDEX
228
        )
228
        )
229
    }
229
    }
230
);
230
);
(-)a/misc/search_tools/rebuild_elastic_search.pl (-2 / +2 lines)
Lines 136-142 if ($index_biblios) { Link Here
136
            $records->next();
136
            $records->next();
137
        }
137
        }
138
    }
138
    }
139
    do_reindex($next, $Koha::ElasticSearch::BIBLIOS_INDEX);
139
    do_reindex($next, Koha::ElasticSearch::BIBLIOS_INDEX);
140
}
140
}
141
if ($index_authorities) {
141
if ($index_authorities) {
142
    _log(1, "Indexing authorities\n");
142
    _log(1, "Indexing authorities\n");
Lines 153-159 if ($index_authorities) { Link Here
153
            $records->next();
153
            $records->next();
154
        }
154
        }
155
    }
155
    }
156
    do_reindex($next, $Koha::ElasticSearch::AUTHORITIES_INDEX);
156
    do_reindex($next, Koha::ElasticSearch::AUTHORITIES_INDEX);
157
}
157
}
158
158
159
sub do_reindex {
159
sub do_reindex {
(-)a/opac/opac-authorities-home.pl (-2 / +2 lines)
Lines 59-67 if ( $op eq "do_search" ) { Link Here
59
59
60
    my @tags;
60
    my @tags;
61
    my $builder = Koha::SearchEngine::QueryBuilder->new(
61
    my $builder = Koha::SearchEngine::QueryBuilder->new(
62
        { index => $Koha::SearchEngine::AUTHORITIES_INDEX } );
62
        { index => Koha::SearchEngine::AUTHORITIES_INDEX } );
63
    my $searcher = Koha::SearchEngine::Search->new(
63
    my $searcher = Koha::SearchEngine::Search->new(
64
        { index => $Koha::SearchEngine::AUTHORITIES_INDEX } );
64
        { index => Koha::SearchEngine::AUTHORITIES_INDEX } );
65
    my $search_query = $builder->build_authorities_query_compat( \@marclist, \@and_or,
65
    my $search_query = $builder->build_authorities_query_compat( \@marclist, \@and_or,
66
        \@excluding, \@operator, \@value, $authtypecode, $orderby );
66
        \@excluding, \@operator, \@value, $authtypecode, $orderby );
67
    my ( $results, $total ) =
67
    my ( $results, $total ) =
(-)a/serials/subscription-bib-search.pl (-2 / +1 lines)
Lines 99-105 if ( $op eq "do_search" && $query ) { Link Here
99
    $resultsperpage = $input->param('resultsperpage');
99
    $resultsperpage = $input->param('resultsperpage');
100
    $resultsperpage = 20 if ( !defined $resultsperpage );
100
    $resultsperpage = 20 if ( !defined $resultsperpage );
101
101
102
    my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
102
    my $searcher = Koha::SearchEngine::Search->new({index => Koha::SearchEngine::BIBLIOS_INDEX});
103
    my ( $error, $marcrecords, $total_hits ) =
103
    my ( $error, $marcrecords, $total_hits ) =
104
      $searcher->simple_search_compat( $query, $startfrom * $resultsperpage, $resultsperpage );
104
      $searcher->simple_search_compat( $query, $startfrom * $resultsperpage, $resultsperpage );
105
    my $total = 0;
105
    my $total = 0;
106
- 

Return to bug 16588