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 2978-2985 sub ModZebra { Link Here
2978
        my $indexer = Koha::SearchEngine::Elasticsearch::Indexer->new(
2978
        my $indexer = Koha::SearchEngine::Elasticsearch::Indexer->new(
2979
            {
2979
            {
2980
                index => $server eq 'biblioserver'
2980
                index => $server eq 'biblioserver'
2981
                ? $Koha::SearchEngine::BIBLIOS_INDEX
2981
                ? Koha::SearchEngine::BIBLIOS_INDEX
2982
                : $Koha::SearchEngine::AUTHORITIES_INDEX
2982
                : Koha::SearchEngine::AUTHORITIES_INDEX
2983
            }
2983
            }
2984
        );
2984
        );
2985
        if ( $op eq 'specialUpdate' ) {
2985
        if ( $op eq 'specialUpdate' ) {
(-)a/C4/Items.pm (-1 / +1 lines)
Lines 2553-2559 sub GetAnalyticsCount { Link Here
2553
    ### ZOOM search here
2553
    ### ZOOM search here
2554
    my $query;
2554
    my $query;
2555
    $query= "hi=".$itemnumber;
2555
    $query= "hi=".$itemnumber;
2556
    my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
2556
    my $searcher = Koha::SearchEngine::Search->new({index => Koha::SearchEngine::BIBLIOS_INDEX});
2557
    my ($err,$res,$result) = $searcher->simple_search_compat($query,0,10);
2557
    my ($err,$res,$result) = $searcher->simple_search_compat($query,0,10);
2558
    return ($result);
2558
    return ($result);
2559
}
2559
}
(-)a/C4/Matcher.pm (-1 / +1 lines)
Lines 660-666 sub get_matches { Link Here
660
                    #NOTE: double-quote the values so you don't get a "Embedded truncation not supported" error when a term has a ? in it.
660
                    #NOTE: double-quote the values so you don't get a "Embedded truncation not supported" error when a term has a ? in it.
661
            }
661
            }
662
662
663
            my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
663
            my $searcher = Koha::SearchEngine::Search->new({index => Koha::SearchEngine::BIBLIOS_INDEX});
664
            ( $error, $searchresults, $total_hits ) =
664
            ( $error, $searchresults, $total_hits ) =
665
              $searcher->simple_search_compat( $query, 0, $max_matches );
665
              $searcher->simple_search_compat( $query, 0, $max_matches );
666
        }
666
        }
(-)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/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/Elasticsearch.pm (-3 / +4 lines)
Lines 28-34 use Koha::SearchMarcMaps; Link Here
28
use Carp;
28
use Carp;
29
use JSON;
29
use JSON;
30
use Modern::Perl;
30
use Modern::Perl;
31
use Readonly;
32
use YAML::Syck;
31
use YAML::Syck;
33
32
34
use Data::Dumper;    # TODO remove
33
use Data::Dumper;    # TODO remove
Lines 37-44 __PACKAGE__->mk_ro_accessors(qw( index )); Link Here
37
__PACKAGE__->mk_accessors(qw( sort_fields ));
36
__PACKAGE__->mk_accessors(qw( sort_fields ));
38
37
39
# Constants to refer to the standard index names
38
# Constants to refer to the standard index names
40
Readonly our $BIBLIOS_INDEX     => 'biblios';
39
use constant {
41
Readonly our $AUTHORITIES_INDEX => 'authorities';
40
    BIBLIOS_INDEX     => 'biblios',
41
    AUTHORITIES_INDEX => 'authorities',
42
};
42
43
43
=head1 NAME
44
=head1 NAME
44
45
(-)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 462-470 my $expanded_facet = $params->{'expand'}; Link Here
462
my ( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type);
462
my ( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type);
463
463
464
my $builder = Koha::SearchEngine::QueryBuilder->new(
464
my $builder = Koha::SearchEngine::QueryBuilder->new(
465
    { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
465
    { index => Koha::SearchEngine::BIBLIOS_INDEX } );
466
my $searcher = Koha::SearchEngine::Search->new(
466
my $searcher = Koha::SearchEngine::Search->new(
467
    { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
467
    { index => Koha::SearchEngine::BIBLIOS_INDEX } );
468
468
469
## I. BUILD THE QUERY
469
## I. BUILD THE QUERY
470
(
470
(
(-)a/cataloguing/addbooks.pl (-2 / +2 lines)
Lines 68-76 if ($query) { Link Here
68
    $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
68
    $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
69
    my $builtquery;
69
    my $builtquery;
70
    my $builder = Koha::SearchEngine::QueryBuilder->new(
70
    my $builder = Koha::SearchEngine::QueryBuilder->new(
71
        { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
71
        { index => Koha::SearchEngine::BIBLIOS_INDEX } );
72
    my $searcher = Koha::SearchEngine::Search->new(
72
    my $searcher = Koha::SearchEngine::Search->new(
73
        { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
73
        { index => Koha::SearchEngine::BIBLIOS_INDEX } );
74
    if ($QParser) {
74
    if ($QParser) {
75
        $builtquery = $query;
75
        $builtquery = $query;
76
    } else {
76
    } else {
(-)a/cataloguing/value_builder/marc21_linking_section.pl (-1 / +1 lines)
Lines 182-188 my $launcher = sub { Link Here
182
            $op = 'and';
182
            $op = 'and';
183
        }
183
        }
184
        my $searcher = Koha::SearchEngine::Search->new(
184
        my $searcher = Koha::SearchEngine::Search->new(
185
            { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
185
            { index => Koha::SearchEngine::BIBLIOS_INDEX } );
186
        $search = 'kw:' . $search . " $op mc-itemtype:" . $itype if $itype;
186
        $search = 'kw:' . $search . " $op mc-itemtype:" . $itype if $itype;
187
        my ( $errors, $results, $total_hits ) =
187
        my ( $errors, $results, $total_hits ) =
188
          $searcher->simple_search_compat( $search,
188
          $searcher->simple_search_compat( $search,
(-)a/cataloguing/value_builder/unimarc_field_4XX.pl (-1 / +1 lines)
Lines 368-374 sub plugin { Link Here
368
            $op = 'and';
368
            $op = 'and';
369
        }
369
        }
370
        $search = 'kw:'.$search." $op mc-itemtype:".$itype if $itype;
370
        $search = 'kw:'.$search." $op mc-itemtype:".$itype if $itype;
371
        my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
371
        my $searcher = Koha::SearchEngine::Search->new({index => Koha::SearchEngine::BIBLIOS_INDEX});
372
        my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat($search, $startfrom * $resultsperpage, $resultsperpage );
372
        my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat($search, $startfrom * $resultsperpage, $resultsperpage );
373
        if (defined $errors ) {
373
        if (defined $errors ) {
374
            $results = [];
374
            $results = [];
(-)a/circ/circulation.pl (-1 / +1 lines)
Lines 355-361 if (@$barcodes) { Link Here
355
    {
355
    {
356
     $template_params->{FALLBACK} = 1;
356
     $template_params->{FALLBACK} = 1;
357
357
358
        my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
358
        my $searcher = Koha::SearchEngine::Search->new({index => Koha::SearchEngine::BIBLIOS_INDEX});
359
        my $query = "kw=" . $barcode;
359
        my $query = "kw=" . $barcode;
360
        my ( $searcherror, $results, $total_hits ) = $searcher->simple_search_compat($query, 0, 10);
360
        my ( $searcherror, $results, $total_hits ) = $searcher->simple_search_compat($query, 0, 10);
361
361
(-)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::SearchEngine::Elasticsearch::BIBLIOS_INDEX);
139
    do_reindex($next, Koha::SearchEngine::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::SearchEngine::Elasticsearch::AUTHORITIES_INDEX);
156
    do_reindex($next, Koha::SearchEngine::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 $offset = ( $startfrom - 1 ) * $resultsperpage + 1;
67
    my $offset = ( $startfrom - 1 ) * $resultsperpage + 1;
(-)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