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

(-)a/Koha/MetaSearcher.pm (-37 / +131 lines)
Lines 56-64 sub new { Link Here
56
}
56
}
57
57
58
sub handle_hit {
58
sub handle_hit {
59
    my ( $self, $index, $server, $marcrecord ) = @_;
59
    my ( $self, $index, $server, $hit ) = @_;
60
60
61
    my $record = Koha::MetadataRecord->new( { schema => 'marc', record => $marcrecord } );
61
    my $record = Koha::MetadataRecord->new( { schema => 'marc', record => $hit->{record} } );
62
62
63
    my %fetch = (
63
    my %fetch = (
64
        title => 'biblio.title',
64
        title => 'biblio.title',
Lines 79-93 sub handle_hit { Link Here
79
    $metadata->{date} //= $metadata->{date2};
79
    $metadata->{date} //= $metadata->{date2};
80
80
81
    push @{ $self->{results} }, {
81
    push @{ $self->{results} }, {
82
        %$hit,
82
        server => $server,
83
        server => $server,
83
        index => $index,
84
        index => $index,
84
        record => $marcrecord,
85
        metadata => $metadata,
85
        metadata => $metadata,
86
    };
86
    };
87
}
87
}
88
88
89
sub search {
89
sub search {
90
    my ( $self, $server_ids, $query ) = @_;
90
    my ( $self, $server_ids, $terms ) = @_;
91
91
92
    my $resultset_expiry = 300;
92
    my $resultset_expiry = 300;
93
93
Lines 142-148 sub search { Link Here
142
            }
142
            }
143
        }
143
        }
144
144
145
        $select->add( $self->_start_worker( $server, $query ) );
145
        $select->add( $self->_start_worker( $server, $terms ) );
146
    }
146
    }
147
147
148
    # Handle these while the servers are searching
148
    # Handle these while the servers are searching
Lines 182-189 sub search { Link Here
182
    return $stats;
182
    return $stats;
183
}
183
}
184
184
185
our $_pqf_mapping = {
186
    author => '1=1004',
187
    'cn-dewey' => '1=13',
188
    'cn-lc' => '1=16',
189
    date => '1=30',
190
    isbn => '1=7',
191
    issn => '1=8',
192
    keyword => '1=1016',
193
    lccn => '1=9',
194
    'local-number' => '1=12',
195
    'music-identifier' => '1=51',
196
    'standard-identifier' => '1=1007',
197
    subject => '1=21',
198
    title => '1=4',
199
};
200
201
our $_batch_db_mapping = {
202
    author => 'import_biblios.author',
203
    isbn => 'import_biblios.isbn',
204
    issn => 'import_biblios.issn',
205
    'local-number' => 'import_biblios.control_number',
206
    title => 'import_biblios.title',
207
};
208
209
our $_batch_db_text_columns = {
210
    author => 1,
211
    keyword => 1,
212
    title => 1,
213
};
214
215
sub _pqf_query_from_terms {
216
    my ( $terms ) = @_;
217
218
    my $query;
219
220
    while ( my ( $index, $value ) = each %$terms ) {
221
        $value =~ s/"/\\"/;
222
223
        my $term = '@attr ' . $_pqf_mapping->{$index} . ' "' . $value . '"';
224
225
        if ( $query ) {
226
            $query = '@and ' . $query . ' ' . $term;
227
        } else {
228
            $query = $term;
229
        }
230
    }
231
232
    return $query;
233
}
234
235
sub _db_query_get_match_conditions {
236
    my ( $index, $value ) = @_;
237
238
    if ( $value =~ /\*/ ) {
239
        $value =~ s/\*/%/;
240
        return { -like => $value };
241
    } elsif ( $_batch_db_text_columns->{$index} ) {
242
        return map +{ -regexp => '[[:<:]]' . $_ . '[[:>:]]' }, split( /\s+/, $value );
243
    } else {
244
        return $value;
245
    }
246
}
247
248
sub _batch_db_query_from_terms {
249
    my ( $import_batch_id, $terms ) = @_;
250
251
    my @db_terms;
252
253
    while ( my ( $index, $value ) = each %$terms ) {
254
        if ( $index eq 'keyword' ) {
255
            my @term;
256
257
            while ( my ( $index, $db_column ) = each %$_batch_db_mapping ) {
258
                push @term, { $db_column => [ _db_query_get_match_conditions( $index, $value ) ] };
259
            }
260
261
            # These are implicitly joined with OR because the arrayref doesn't start with -and
262
            push @db_terms, \@term;
263
        } elsif ( $_batch_db_mapping->{$index} ) {
264
            push @db_terms, $_batch_db_mapping->{$index} => [ -and => _db_query_get_match_conditions( $index, $value ) ];
265
        } else {
266
            # No such index, we should fail
267
            return undef;
268
        }
269
    }
270
271
    return {
272
        -and => [
273
            import_batch_id => $import_batch_id,
274
            @db_terms
275
        ],
276
    },
277
}
278
185
sub _start_worker {
279
sub _start_worker {
186
    my ( $self, $server, $query ) = @_;
280
    my ( $self, $server, $terms ) = @_;
187
    pipe my $readfh, my $writefh;
281
    pipe my $readfh, my $writefh;
188
282
189
    # Accessing the cache or Koha database after the fork is risky, so get any resources we need
283
    # Accessing the cache or Koha database after the fork is risky, so get any resources we need
Lines 207-212 sub _start_worker { Link Here
207
    my $connection;
301
    my $connection;
208
    my ( $num_hits, $num_fetched, $hits, $results );
302
    my ( $num_hits, $num_fetched, $hits, $results );
209
303
304
    my $pqf_query = _pqf_query_from_terms( $terms );
305
210
    eval {
306
    eval {
211
        if ( $server->{type} eq 'z3950' ) {
307
        if ( $server->{type} eq 'z3950' ) {
212
            my $zoptions = ZOOM::Options->new();
308
            my $zoptions = ZOOM::Options->new();
Lines 220-285 sub _start_worker { Link Here
220
            $connection = ZOOM::Connection->create($zoptions);
316
            $connection = ZOOM::Connection->create($zoptions);
221
317
222
            $connection->connect( $server->{host}, $server->{port} );
318
            $connection->connect( $server->{host}, $server->{port} );
223
            $results = $connection->search_pqf( $query ); # Starts the search
319
            $results = $connection->search_pqf( $pqf_query ); # Starts the search
224
        } elsif ( $server->{type} eq 'koha' ) {
320
        } elsif ( $server->{type} eq 'koha' ) {
225
            $connection = C4::Context->Zconn( $server->{extra} );
321
            $connection = C4::Context->Zconn( $server->{extra} );
226
            $results = $connection->search_pqf( $query ); # Starts the search
322
            $results = $connection->search_pqf( $pqf_query ); # Starts the search
227
        } elsif ( $server->{type} eq 'batch' )  {
323
        } elsif ( $server->{type} eq 'batch' )  {
228
            $server->{encoding} = 'utf-8';
324
            $server->{encoding} = 'utf-8';
229
        }
325
        }
230
    };
326
    };
231
    if ($@) {
327
    if ($@) {
232
        store_fd {
328
        store_fd {
233
            error => $connection ? $connection->exception() : $@,
329
            error => $connection ? $connection->exception()->message() : $@,
234
            server => $server,
330
            server => $server,
235
        }, $writefh;
331
        }, $writefh;
236
        exit;
332
        exit;
237
    }
333
    }
238
334
335
    my $error;
239
    if ( $server->{type} eq 'batch' ) {
336
    if ( $server->{type} eq 'batch' ) {
240
        # TODO: actually handle PQF
241
        $query =~ s/@\w+ (?:\d+=\d+ )?//g;
242
        $query =~ s/"//g;
243
244
        my $schema = Koha::Database->new->schema;
337
        my $schema = Koha::Database->new->schema;
245
        $schema->storage->debug(1);
338
        my $db_query = _batch_db_query_from_terms( $server->{extra}, $terms );
246
        my $match_condition = [ map +{ -like => '%' . $_ . '%' }, split( /\s+/, $query ) ];
339
247
        $hits = [ $schema->resultset('ImportRecord')->search(
340
        if ( $db_query ) {
248
            {
341
            $hits = [ $schema->resultset('ImportRecord')->search(
249
                import_batch_id => $server->{extra},
342
                $db_query,
250
                -or => [
343
                {
251
                    { 'import_biblios.title' => $match_condition },
344
                    columns => [ 'import_record_id', { record => 'marc' } ],
252
                    { 'import_biblios.author' => $match_condition },
345
                    join => [ 'import_biblios' ],
253
                    { 'import_biblios.isbn' => $match_condition },
346
                    offset => $self->{offset},
254
                    { 'import_biblios.issn' => $match_condition },
347
                    result_class => 'DBIx::Class::ResultClass::HashRefInflator',
255
                ],
348
                    rows => $self->{fetch},
256
            },
349
                }
257
            {
350
            )->all ];
258
                join => [ qw( import_biblios ) ],
351
259
                rows => $self->{fetch},
352
            $num_hits = $num_fetched = scalar @$hits;
260
            }
353
        } else {
261
        )->get_column( 'marc' )->all ];
354
            $error = "Invalid search";
262
355
        }
263
        $num_hits = $num_fetched = scalar @$hits;
264
    } else {
356
    } else {
265
        $num_hits = $results->size;
357
        $num_hits = $results->size;
266
        $num_fetched = ( $self->{offset} + $self->{fetch} ) < $num_hits ? $self->{fetch} : $num_hits;
358
        $num_fetched = ( $self->{offset} + $self->{fetch} ) < $num_hits ? $self->{fetch} : $num_hits;
267
359
268
        $hits = [ map { $_->raw() } @{ $results->records( $self->{offset}, $num_fetched, 1 ) } ];
360
        $hits = [ map +{ record => $_->raw() }, @{ $results->records( $self->{offset}, $num_fetched, 1 ) } ];
361
362
        $error = $connection->exception()->message() if ( !@$hits && $connection && $connection->exception() );
269
    }
363
    }
270
364
271
    if ( !@$hits && $connection && $connection->exception() ) {
365
    if ( $error ) {
272
        store_fd {
366
        store_fd {
273
            error => $connection->exception(),
367
            error => $error,
274
            server => $server,
368
            server => $server,
275
        }, $writefh;
369
        }, $writefh;
276
        exit;
370
        exit;
277
    }
371
    }
278
372
279
    if ( $server->{type} eq 'koha' ) {
373
    if ( $server->{type} eq 'koha' ) {
280
        $hits = [ map { C4::Search::new_record_from_zebra( $server->{extra}, $_ ) } @$hits ];
374
        $hits = [ map +{ %$_, record => C4::Search::new_record_from_zebra( $server->{extra}, $_->{record} ) }, @$hits ];
281
    } else {
375
    } else {
282
        $hits = [ map { $self->_import_record( $_, $marcflavour, $server->{encoding} ? $server->{encoding} : "iso-5426" ) } @$hits ];
376
        $hits = [ map +{ %$_, record => $self->_import_record( $_->{record}, $marcflavour, $server->{encoding} ? $server->{encoding} : "iso-5426" ) }, @$hits ];
283
    }
377
    }
284
378
285
    store_fd {
379
    store_fd {
(-)a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/search.js (-37 / +11 lines)
Lines 22-63 define( [ 'koha-backend', 'marc-record' ], function( KohaBackend, MARC ) { Link Here
22
    var _records = {};
22
    var _records = {};
23
    var _last;
23
    var _last;
24
24
25
    var _pqfMapping = {
26
        author: '1=1004', // s=al',
27
        cn_dewey: '1=13',
28
        cn_lc: '1=16',
29
        date: '1=30', // r=r',
30
        isbn: '1=7',
31
        issn: '1=8',
32
        lccn: '1=9',
33
        local_number: '1=12',
34
        music_identifier: '1=51',
35
        standard_identifier: '1=1007',
36
        subject: '1=21', // s=al',
37
        term: '1=1016', // t=l,r s=al',
38
        title: '1=4', // s=al',
39
    }
40
41
    var Search = {
25
    var Search = {
42
        Init: function( options ) {
26
        Init: function( options ) {
43
            _options = options;
27
            _options = options;
44
        },
28
        },
45
        JoinTerms: function( terms ) {
29
        Run: function( servers, terms, options ) {
46
            var q = '';
47
48
            $.each( terms, function( i, term ) {
49
                var term = '@attr ' + _pqfMapping[ term[0] ] + ' "' + term[1].replace( '"', '\\"' ) + '"'
50
51
                if ( q ) {
52
                    q = '@and ' + q + ' ' + term;
53
                } else {
54
                    q = term;
55
                }
56
            } );
57
58
            return q;
59
        },
60
        Run: function( servers, q, options ) {
61
            options = $.extend( {
30
            options = $.extend( {
62
                offset: 0,
31
                offset: 0,
63
                page_size: 20,
32
                page_size: 20,
Lines 67-76 define( [ 'koha-backend', 'marc-record' ], function( KohaBackend, MARC ) { Link Here
67
            _records = {};
36
            _records = {};
68
            _last = {
37
            _last = {
69
                servers: servers,
38
                servers: servers,
70
                q: q,
39
                terms: terms,
71
                options: options,
40
                options: options,
72
            };
41
            };
73
42
43
            var newTerms = {};
44
            $.each( terms, function( index, value ) {
45
                newTerms[ "term-" + index ] = value;
46
            } );
47
            terms = newTerms;
48
74
            var itemTag = KohaBackend.GetSubfieldForKohaField('items.itemnumber')[0];
49
            var itemTag = KohaBackend.GetSubfieldForKohaField('items.itemnumber')[0];
75
50
76
            $.each( servers, function ( id, info ) {
51
            $.each( servers, function ( id, info ) {
Lines 81-95 define( [ 'koha-backend', 'marc-record' ], function( KohaBackend, MARC ) { Link Here
81
56
82
            $.get(
57
            $.get(
83
                '/cgi-bin/koha/svc/cataloguing/metasearch',
58
                '/cgi-bin/koha/svc/cataloguing/metasearch',
84
                {
59
                $.extend( {
85
                    q: q,
86
                    servers: Search.includedServers.join( ',' ),
60
                    servers: Search.includedServers.join( ',' ),
87
                    offset: options.offset,
61
                    offset: options.offset,
88
                    page_size: options.page_size,
62
                    page_size: options.page_size,
89
                    sort_direction: options.sort_direction,
63
                    sort_direction: options.sort_direction,
90
                    sort_key: options.sort_key,
64
                    sort_key: options.sort_key,
91
                    resultset: options.resultset,
65
                    resultset: options.resultset,
92
                }
66
                }, terms )
93
            )
67
            )
94
                .done( function( data ) {
68
                .done( function( data ) {
95
                    _last.options.resultset = data.resultset;
69
                    _last.options.resultset = data.resultset;
Lines 115-121 define( [ 'koha-backend', 'marc-record' ], function( KohaBackend, MARC ) { Link Here
115
        Fetch: function( options ) {
89
        Fetch: function( options ) {
116
            if ( !_last ) return;
90
            if ( !_last ) return;
117
            $.extend( _last.options, options );
91
            $.extend( _last.options, options );
118
            return Search.Run( _last.servers, _last.q, _last.options );
92
            return Search.Run( _last.servers, _last.terms, _last.options );
119
        }
93
        }
120
    };
94
    };
121
95
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc (-27 / +16 lines)
Lines 164-180 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
164
164
165
        $('#quicksearch .search-box').each( function() {
165
        $('#quicksearch .search-box').each( function() {
166
            shortcut.add( 'enter', $.proxy( function() {
166
            shortcut.add( 'enter', $.proxy( function() {
167
                var terms = [];
167
                var terms = {};
168
168
169
                $('#quicksearch .search-box').each( function() {
169
                $('#quicksearch .search-box').each( function() {
170
                    if ( !this.value ) return;
170
                    if ( !this.value ) return;
171
171
172
                    terms.push( [ $(this).data('qualifier'), this.value ] );
172
                    terms[ $(this).data('qualifier') ] = this.value;
173
                } );
173
                } );
174
174
175
                if ( !terms.length ) return;
175
                if ( $.isEmptyObject(terms) ) return;
176
176
177
                if ( Search.Run( z3950Servers, Search.JoinTerms(terms) ) ) {
177
                if ( Search.Run( z3950Servers, terms ) ) {
178
                    $("#search-overlay").show();
178
                    $("#search-overlay").show();
179
                    showResultsBox();
179
                    showResultsBox();
180
                }
180
                }
Lines 464-480 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
464
    }
464
    }
465
465
466
    function startAdvancedSearch() {
466
    function startAdvancedSearch() {
467
        var terms = [];
467
        var terms = {};
468
468
469
        $('#advanced-search-ui .search-box').each( function() {
469
        $('#advanced-search-ui .search-box').each( function() {
470
            if ( !this.value ) return;
470
            if ( !this.value ) return;
471
471
472
            terms.push( [ $(this).data('qualifier'), this.value ] );
472
            terms[ $(this).data('qualifier') ] = this.value;
473
        } );
473
        } );
474
474
475
        if ( !terms.length ) return;
475
        if ( $.isEmptyObject(terms) ) return;
476
476
477
        if ( Search.Run( z3950Servers, Search.JoinTerms(terms) ) ) {
477
        if ( Search.Run( z3950Servers, terms ) ) {
478
            $('#advanced-search-ui').modal('hide');
478
            $('#advanced-search-ui').modal('hide');
479
            $("#search-overlay").show();
479
            $("#search-overlay").show();
480
            showResultsBox();
480
            showResultsBox();
Lines 547-565 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
547
        $.each( data.hits, function( undef, hit ) {
547
        $.each( data.hits, function( undef, hit ) {
548
            backends.search.records[ hit.server + ':' + hit.index ] = hit.record;
548
            backends.search.records[ hit.server + ':' + hit.index ] = hit.record;
549
549
550
            switch ( hit.server ) {
550
            hit.id = 'search/' + hit.server + ':' + hit.index;
551
                case 'koha:biblioserver':
551
            if ( hit.server == 'koha:biblioserver' ) {
552
                    var bibnumField = hit.record.field( bibnumMap[0] );
552
                var bibnumField = hit.record.field( bibnumMap[0] );
553
553
554
                    if ( bibnumField && bibnumField.hasSubfield( bibnumMap[1] ) ) {
554
                if ( bibnumField && bibnumField.hasSubfield( bibnumMap[1] ) ) {
555
                        hit.id = 'catalog/' + bibnumField.subfield( bibnumMap[1] );
555
                    hit.id = 'catalog/' + bibnumField.subfield( bibnumMap[1] );
556
                        break;
556
                }
557
                    }
557
            } else if ( /^batch:/.test(hit.server) && hit.import_record_id ) {
558
558
                hit.id = hit.server + '/' + hit.import_record_id;
559
                    // Otherwise, fallthrough
560
561
                default:
562
                    hit.id = 'search/' + hit.server + ':' + hit.index;
563
            }
559
            }
564
560
565
            var result = '<tr>';
561
            var result = '<tr>';
Lines 711-723 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
711
                    if ( saved_val != null ) setSaveTargetChecked( target_id, saved_val );
707
                    if ( saved_val != null ) setSaveTargetChecked( target_id, saved_val );
712
                } );
708
                } );
713
                break;
709
                break;
714
            case 'selected_search_targets':
715
                $.each( z3950Servers, function( server_id, server ) {
716
                    var saved_val = Preferences.user.selected_search_targets[server_id];
717
718
                    if ( saved_val != null ) server.checked = saved_val;
719
                } );
720
                break;
721
        }
710
        }
722
    }
711
    }
723
712
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt (-6 / +6 lines)
Lines 84-90 Link Here
84
    <fieldset class="brief">
84
    <fieldset class="brief">
85
    <ol>
85
    <ol>
86
        <li><label for="search-by-keywords">Keywords:</label></li>
86
        <li><label for="search-by-keywords">Keywords:</label></li>
87
        <li><input class="search-box" data-qualifier="term" id="search-by-keywords" placeholder="(Ctrl-Alt-K)" /></li>
87
        <li><input class="search-box" data-qualifier="keyword" id="search-by-keywords" placeholder="(Ctrl-Alt-K)" /></li>
88
        <li><label for="search-by-author">Author:</label></li>
88
        <li><label for="search-by-author">Author:</label></li>
89
        <li><input class="search-box" data-qualifier="author" id="search-by-author" placeholder="(Ctrl-Alt-A)" /></li>
89
        <li><input class="search-box" data-qualifier="author" id="search-by-author" placeholder="(Ctrl-Alt-A)" /></li>
90
        <li><label for="search-by-isbn">ISBN:</label></li>
90
        <li><label for="search-by-isbn">ISBN:</label></li>
Lines 153-159 Link Here
153
            </li>
153
            </li>
154
            <li>
154
            <li>
155
                <label for="advanced-search-by-lc-number">LC call number:</label>
155
                <label for="advanced-search-by-lc-number">LC call number:</label>
156
                <input class="search-box" data-qualifier="cn_lc" id="advanced-search-by-lc-number" />
156
                <input class="search-box" data-qualifier="cn-lc" id="advanced-search-by-lc-number" />
157
            </li>
157
            </li>
158
            <li>
158
            <li>
159
                <label for="advanced-search-by-lccn">LCCN:</label>
159
                <label for="advanced-search-by-lccn">LCCN:</label>
Lines 161-179 Link Here
161
            </li>
161
            </li>
162
            <li>
162
            <li>
163
                <label for="advanced-search-by-control-number">Control number:</label>
163
                <label for="advanced-search-by-control-number">Control number:</label>
164
                <input class="search-box" data-qualifier="local_number" id="advanced-search-by-control-number" />
164
                <input class="search-box" data-qualifier="local-number" id="advanced-search-by-control-number" />
165
            </li>
165
            </li>
166
            <li>
166
            <li>
167
                <label for="advanced-search-by-dewey">Dewey number:</label>
167
                <label for="advanced-search-by-dewey">Dewey number:</label>
168
                <input class="search-box" data-qualifier="cn_dewey" id="advanced-search-by-dewey" />
168
                <input class="search-box" data-qualifier="cn-dewey" id="advanced-search-by-dewey" />
169
            </li>
169
            </li>
170
            <li>
170
            <li>
171
                <label for="advanced-search-by-standard-number">Standard number:</label>
171
                <label for="advanced-search-by-standard-number">Standard number:</label>
172
                <input class="search-box" data-qualifier="standard_identifier" id="advanced-search-by-standard-number" />
172
                <input class="search-box" data-qualifier="standard-identifier" id="advanced-search-by-standard-number" />
173
            </li>
173
            </li>
174
            <li>
174
            <li>
175
                <label for="advanced-search-by-publisher-number">Publisher number:</label>
175
                <label for="advanced-search-by-publisher-number">Publisher number:</label>
176
                <input class="search-box" data-qualifier="music_identifier" id="advanced-search-by-publisher-number" />
176
                <input class="search-box" data-qualifier="music-identifier" id="advanced-search-by-publisher-number" />
177
            </li>
177
            </li>
178
            <li>
178
            <li>
179
                <label for="advanced-search-by-publication-date">Publication date:</label>
179
                <label for="advanced-search-by-publication-date">Publication date:</label>
(-)a/svc/cataloguing/metasearch (-5 / +13 lines)
Lines 25-31 use Koha::MetaSearcher; Link Here
25
25
26
my ( $query, $response ) = C4::Service->init( catalogue => 1 );
26
my ( $query, $response ) = C4::Service->init( catalogue => 1 );
27
27
28
my ( $query_string, $servers ) = C4::Service->require_params( 'q', 'servers' );
28
my ( $servers ) = C4::Service->require_params( 'servers' );
29
29
30
my $server_errors = {};
30
my $server_errors = {};
31
31
Lines 35-53 my $offset = $query->param( 'offset' ) || 0; Link Here
35
my $page_size = $query->param( 'page_size' ) || 20;
35
my $page_size = $query->param( 'page_size' ) || 20;
36
my $fetched = $query->param( 'fetched' ) || 100;
36
my $fetched = $query->param( 'fetched' ) || 100;
37
37
38
my $terms = {};
39
40
foreach my $term ( $query->param ) {
41
    next unless ( $term =~ /^term-([A-Za-z0-9-]+)/ );
42
43
    $terms->{$1} = $query->param($term);
44
}
45
38
my $searcher = Koha::MetaSearcher->new( {
46
my $searcher = Koha::MetaSearcher->new( {
39
    fetched => $fetched,
47
    fetched => $fetched,
40
    on_error => sub {
48
    on_error => sub {
41
        my ( $server, $exception ) = @_;
49
        my ( $server, $exception ) = @_;
42
50
43
        $server_errors->{ $server->{id} } = $exception->message;
51
        $server_errors->{ $server->{id} } = $exception;
44
    },
52
    },
45
} );
53
} );
46
54
47
$searcher->resultset( $query->param('resultset') ) if ( $query->param('resultset') );
55
$searcher->resultset( $query->param('resultset') ) if ( $query->param('resultset') );
48
56
49
my @server_ids = split( /,/, $servers );
57
my @server_ids = split( /,/, $servers );
50
my $stats = $searcher->search( \@server_ids, $query_string );
58
my $stats = $searcher->search( \@server_ids, $terms );
51
59
52
$searcher->sort( $sort_key, $sort_direction eq 'desc' ? -1 : 1 );
60
$searcher->sort( $sort_key, $sort_direction eq 'desc' ? -1 : 1 );
53
61
Lines 55-64 my @hits; Link Here
55
63
56
foreach my $hit ( $searcher->results( $offset, $page_size ) ) {
64
foreach my $hit ( $searcher->results( $offset, $page_size ) ) {
57
    push @hits, {
65
    push @hits, {
66
        %$hit,
58
        server => $hit->{server}->{id},
67
        server => $hit->{server}->{id},
59
        index => $hit->{index},
68
        index => $hit->{index},
60
        record => $hit->{record}->as_xml_record(),
69
        record => $hit->{record}->as_xml_record(),
61
        metadata => $hit->{metadata}
70
        metadata => $hit->{metadata},
62
    };
71
    };
63
}
72
}
64
73
65
- 

Return to bug 18823