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

(-)a/C4/AuthoritiesMarc.pm (-14 / +19 lines)
Lines 266-275 sub SearchAuthorities { Link Here
266
        
266
        
267
        ##Here we have to extract MARC record and $authid from ZEBRA AUTHORITIES
267
        ##Here we have to extract MARC record and $authid from ZEBRA AUTHORITIES
268
        my $rec=$oAResult->record($counter);
268
        my $rec=$oAResult->record($counter);
269
        my $marcdata=$rec->raw();
270
        my $authrecord;
271
        my $separator=C4::Context->preference('authoritysep');
269
        my $separator=C4::Context->preference('authoritysep');
272
        $authrecord = MARC::File::USMARC::decode($marcdata);
270
        my $authrecord = MARC::Record->new_from_xml(
271
            $rec->raw(),
272
            'UTF-8'
273
        );
273
        my $authid=$authrecord->field('001')->data();
274
        my $authid=$authrecord->field('001')->data();
274
        my %newline;
275
        my %newline;
275
        $newline{authid} = $authid;
276
        $newline{authid} = $authid;
Lines 847-861 sub FindDuplicateAuthority { Link Here
847
    my $query='at:'.$authtypecode.' ';
848
    my $query='at:'.$authtypecode.' ';
848
    my $filtervalues=qr([\001-\040\!\'\"\`\#\$\%\&\*\+,\-\./:;<=>\?\@\(\)\{\[\]\}_\|\~]);
849
    my $filtervalues=qr([\001-\040\!\'\"\`\#\$\%\&\*\+,\-\./:;<=>\?\@\(\)\{\[\]\}_\|\~]);
849
    if ($record->field($auth_tag_to_report)) {
850
    if ($record->field($auth_tag_to_report)) {
850
      foreach ($record->field($auth_tag_to_report)->subfields()) {
851
        foreach ($record->field($auth_tag_to_report)->subfields()) {
851
        $_->[1]=~s/$filtervalues/ /g; $query.= " $op he:\"".$_->[1]."\"" if ($_->[0]=~/[A-z]/);
852
            $_->[1]=~s/$filtervalues/ /g; $query.= " $op he:\"".$_->[1]."\"" if ($_->[0]=~/[A-z]/);
852
      }
853
        }
853
    }
854
    }
854
    my ($error, $results, $total_hits) = C4::Search::SimpleSearch( $query, 0, 1, [ "authorityserver" ] );
855
    my ($error, $results, $total_hits) = C4::Search::SimpleSearch( $query, 0, 1, [ "authorityserver" ] );
855
    # there is at least 1 result => return the 1st one
856
    # there is at least 1 result => return the 1st one
856
    if (!defined $error && @{$results} ) {
857
    if (!defined $error && @{$results} ) {
857
      my $marcrecord = MARC::File::USMARC::decode($results->[0]);
858
        my $marcrecord = MARC::Record->new_from_xml(
858
      return $marcrecord->field('001')->data,BuildSummary($marcrecord,$marcrecord->field('001')->data,$authtypecode);
859
            $results->[0]
860
        );
861
        return $marcrecord->field('001')->data,BuildSummary($marcrecord,$marcrecord->field('001')->data,$authtypecode);
859
    }
862
    }
860
    # no result, returns nothing
863
    # no result, returns nothing
861
    return;
864
    return;
Lines 1452-1464 sub merge { Link Here
1452
    }
1455
    }
1453
    my $z=0;
1456
    my $z=0;
1454
    while ( $z<$count ) {
1457
    while ( $z<$count ) {
1455
        my $rec;
1458
        my $marcrecordzebra= MARC::Record->new_from_xml(
1456
        $rec=$oResult->record($z);
1459
            $oResult->record($z)->raw(),
1457
        my $marcdata = $rec->raw();
1460
            'UTF-8'
1458
        my $marcrecordzebra= MARC::Record->new_from_usmarc($marcdata);
1461
        );
1459
        my ( $biblionumbertagfield, $biblionumbertagsubfield ) = &GetMarcFromKohaField( "biblio.biblionumber", '' );
1462
        my ( $biblionumbertagfield, $biblionumbertagsubfield ) = &GetMarcFromKohaField( "biblio.biblionumber", '' );
1460
        my $i = ($biblionumbertagfield < 10) ? $marcrecordzebra->field($biblionumbertagfield)->data : $marcrecordzebra->subfield($biblionumbertagfield, $biblionumbertagsubfield);
1463
        my $i = ($biblionumbertagfield < 10)
1461
        my $marcrecorddb=GetMarcBiblio($i);
1464
            ? $marcrecordzebra->field( $biblionumbertagfield )->data
1465
            : $marcrecordzebra->subfield( $biblionumbertagfield, $biblionumbertagsubfield );
1466
        my $marcrecorddb = GetMarcBiblio($i);
1462
        push @reccache, $marcrecorddb;
1467
        push @reccache, $marcrecorddb;
1463
        $z++;
1468
        $z++;
1464
    }
1469
    }
(-)a/C4/Context.pm (-5 / +3 lines)
Lines 705-712 sub Zconn { Link Here
705
        $context->{"Zconn"}->{$server}->destroy() if defined($context->{"Zconn"}->{$server});
705
        $context->{"Zconn"}->{$server}->destroy() if defined($context->{"Zconn"}->{$server});
706
706
707
        $context->{"Zconn"}->{$server} = &_new_Zconn($server,$async,$auth,$piggyback,$syntax);
707
        $context->{"Zconn"}->{$server} = &_new_Zconn($server,$async,$auth,$piggyback,$syntax);
708
        $context->{ Zconn }->{ $server }->option(
709
            preferredRecordSyntax => C4::Context->preference("marcflavour") );
710
        return $context->{"Zconn"}->{$server};
708
        return $context->{"Zconn"}->{$server};
711
    }
709
    }
712
}
710
}
Lines 730-737 sub _new_Zconn { Link Here
730
728
731
    my $tried=0; # first attempt
729
    my $tried=0; # first attempt
732
    my $Zconn; # connection object
730
    my $Zconn; # connection object
733
    $server = "biblioserver" unless $server;
731
    $server //= "biblioserver";
734
    $syntax = "usmarc" unless $syntax;
732
    $syntax //= "XML";
735
733
736
    my $host = $context->{'listen'}->{$server}->{'content'};
734
    my $host = $context->{'listen'}->{$server}->{'content'};
737
    my $servername = $context->{"config"}->{$server};
735
    my $servername = $context->{"config"}->{$server};
Lines 749-755 sub _new_Zconn { Link Here
749
        $o->option(cqlfile=> $context->{"server"}->{$server}->{"cql2rpn"});
747
        $o->option(cqlfile=> $context->{"server"}->{$server}->{"cql2rpn"});
750
        $o->option(cclfile=> $context->{"serverinfo"}->{$server}->{"ccl2rpn"});
748
        $o->option(cclfile=> $context->{"serverinfo"}->{$server}->{"ccl2rpn"});
751
        $o->option(preferredRecordSyntax => $syntax);
749
        $o->option(preferredRecordSyntax => $syntax);
752
        $o->option(elementSetName => "F"); # F for 'full' as opposed to B for 'brief'
750
        $o->option(elementSetName => "marcxml");
753
        $o->option(databaseName => ($servername?$servername:"biblios"));
751
        $o->option(databaseName => ($servername?$servername:"biblios"));
754
752
755
        # create a new connection object
753
        # create a new connection object
(-)a/C4/Installer/PerlDependencies.pm (-2 / +2 lines)
Lines 462-468 our $PERL_DEPS = { Link Here
462
    'MARC::Record' => {
462
    'MARC::Record' => {
463
        'usage'    => 'Core',
463
        'usage'    => 'Core',
464
        'required' => '1',
464
        'required' => '1',
465
        'min_ver'  => '2'
465
        'min_ver'  => '2.0.6'
466
    },
466
    },
467
    'Locale::Currency::Format' => {
467
    'Locale::Currency::Format' => {
468
        'usage'    => 'Core',
468
        'usage'    => 'Core',
Lines 487-493 our $PERL_DEPS = { Link Here
487
    'MARC::File::XML' => {
487
    'MARC::File::XML' => {
488
        'usage'    => 'Core',
488
        'usage'    => 'Core',
489
        'required' => '1',
489
        'required' => '1',
490
        'min_ver'  => '0.88'
490
        'min_ver'  => '1.0.1'
491
    },
491
    },
492
    'XML::SAX::Writer' => {
492
    'XML::SAX::Writer' => {
493
        'usage'    => 'Core',
493
        'usage'    => 'Core',
(-)a/C4/Search.pm (-31 / +30 lines)
Lines 144-151 sub FindDuplicate { Link Here
144
    my @results;
144
    my @results;
145
    if (!defined $error) {
145
    if (!defined $error) {
146
        foreach my $possible_duplicate_record (@{$searchresults}) {
146
        foreach my $possible_duplicate_record (@{$searchresults}) {
147
            my $marcrecord =
147
            my $marcrecord = MARC::Record->new_from_xml(
148
            MARC::Record->new_from_usmarc($possible_duplicate_record);
148
                $possible_duplicate_record,
149
                'UTF-8'
150
            );
149
            my $result = TransformMarcToKoha( $dbh, $marcrecord, '' );
151
            my $result = TransformMarcToKoha( $dbh, $marcrecord, '' );
150
152
151
            # FIXME :: why 2 $biblionumber ?
153
            # FIXME :: why 2 $biblionumber ?
Lines 446-451 sub getRecords { Link Here
446
                else {
448
                else {
447
                    $times = $size;
449
                    $times = $size;
448
                }
450
                }
451
449
                for ( my $j = $offset ; $j < $times ; $j++ ) {
452
                for ( my $j = $offset ; $j < $times ; $j++ ) {
450
                    my $records_hash;
453
                    my $records_hash;
451
                    my $record;
454
                    my $record;
Lines 455-461 sub getRecords { Link Here
455
                        my ( $term, $occ ) = $results[ $i - 1 ]->term($j);
458
                        my ( $term, $occ ) = $results[ $i - 1 ]->term($j);
456
459
457
                 # here we create a minimal MARC record and hand it off to the
460
                 # here we create a minimal MARC record and hand it off to the
458
                 # template just like a normal result ... perhaps not ideal, but
461
                 # template just like a normal result ... serhaps not ideal, but
459
                 # it works for now
462
                 # it works for now
460
                        my $tmprecord = MARC::Record->new();
463
                        my $tmprecord = MARC::Record->new();
461
                        $tmprecord->encoding('UTF-8');
464
                        $tmprecord->encoding('UTF-8');
Lines 488-494 sub getRecords { Link Here
488
                    # not an index scan
491
                    # not an index scan
489
                    else {
492
                    else {
490
                        $record = $results[ $i - 1 ]->record($j)->raw();
493
                        $record = $results[ $i - 1 ]->record($j)->raw();
491
492
                        # warn "RECORD $j:".$record;
494
                        # warn "RECORD $j:".$record;
493
                        $results_hash->{'RECORDS'}[$j] = $record;
495
                        $results_hash->{'RECORDS'}[$j] = $record;
494
                    }
496
                    }
Lines 503-541 sub getRecords { Link Here
503
                      $size > $facets_maxrecs ? $facets_maxrecs : $size;
505
                      $size > $facets_maxrecs ? $facets_maxrecs : $size;
504
                    for my $facet (@$facets) {
506
                    for my $facet (@$facets) {
505
                        for ( my $j = 0 ; $j < $jmax ; $j++ ) {
507
                        for ( my $j = 0 ; $j < $jmax ; $j++ ) {
506
                            my $render_record =
508
507
                              $results[ $i - 1 ]->record($j)->render();
509
                            my $marc_record = MARC::Record->new_from_xml(
510
                                $results[ $i - 1 ]->record($j)->raw(),
511
                                'UTF-8'
512
                            );
508
                            my @used_datas = ();
513
                            my @used_datas = ();
514
509
                            foreach my $tag ( @{ $facet->{tags} } ) {
515
                            foreach my $tag ( @{ $facet->{tags} } ) {
510
516
511
                                # avoid first line
517
                                # avoid first line
512
                                my $tag_num = substr( $tag, 0, 3 );
518
                                my $tag_num = substr( $tag, 0, 3 );
513
                                my $letters = substr( $tag, 3 );
519
                                my $subfield_letters = substr( $tag, 3 );
514
                                my $field_pattern =
520
                                # Removed when as_string fixed
515
                                  '\n' . $tag_num . ' ([^z][^\n]+)';
521
                                my @subfields = $subfield_letters =~ /./sg;
516
                                $field_pattern = '\n' . $tag_num . ' ([^\n]+)'
522
517
                                  if ( int($tag_num) < 10 );
523
                                my @fields = $marc_record->field($tag_num);
518
                                my @field_tokens =
524
                                foreach my $field (@fields) {
519
                                  ( $render_record =~ /$field_pattern/g );
525
                                    my $data = $field->as_string( $subfield_letters, $facet->{sep} );
520
                                foreach my $field_token (@field_tokens) {
526
521
                                    my @subf = ( $field_token =~
522
                                          /\$([a-zA-Z0-9]) ([^\$]+)/g );
523
                                    my @values;
524
                                    for ( my $i = 0 ; $i < @subf ; $i += 2 ) {
525
                                        if ( $letters =~ $subf[$i] ) {
526
                                            my $value = $subf[ $i + 1 ];
527
                                            $value =~ s/^ *//;
528
                                            $value =~ s/ *$//;
529
                                            push @values, $value;
530
                                        }
531
                                    }
532
                                    my $data = join( $facet->{sep}, @values );
533
                                    unless ( $data ~~ @used_datas ) {
527
                                    unless ( $data ~~ @used_datas ) {
534
                                        $facets_counter->{ $facet->{idx} }
535
                                          ->{$data}++;
536
                                        push @used_datas, $data;
528
                                        push @used_datas, $data;
537
                                    }
529
                                    }
538
                                }    # fields
530
531
                                    $facets_counter->{ $facet->{idx} }->{$data}++;
532
533
                                } # fields
539
                            }    # field codes
534
                            }    # field codes
540
                        }    # records
535
                        }    # records
541
                        $facets_info->{ $facet->{idx} }->{label_value} =
536
                        $facets_info->{ $facet->{idx} }->{label_value} =
Lines 1695-1707 sub searchResults { Link Here
1695
        $times = $hits;	 # FIXME: if $hits is undefined, why do we want to equal it?
1690
        $times = $hits;	 # FIXME: if $hits is undefined, why do we want to equal it?
1696
    }
1691
    }
1697
1692
1698
	my $marcflavour = C4::Context->preference("marcflavour");
1693
    my $marcflavour = C4::Context->preference("marcflavour");
1699
    # We get the biblionumber position in MARC
1694
    # We get the biblionumber position in MARC
1700
    my ($bibliotag,$bibliosubf)=GetMarcFromKohaField('biblio.biblionumber','');
1695
    my ($bibliotag,$bibliosubf)=GetMarcFromKohaField('biblio.biblionumber','');
1701
1696
1702
    # loop through all of the records we've retrieved
1697
    # loop through all of the records we've retrieved
1703
    for ( my $i = $offset ; $i <= $times - 1 ; $i++ ) {
1698
    for ( my $i = $offset ; $i <= $times - 1 ; $i++ ) {
1704
        my $marcrecord = eval { MARC::File::USMARC::decode( $marcresults->[$i] ); };
1699
        my $marcrecord = eval {  MARC::Record->new_from_xml(
1700
            $marcresults->[$i],
1701
            'UTF-8'
1702
        ); };
1703
1705
        if ( $@ ) {
1704
        if ( $@ ) {
1706
            warn "ERROR DECODING RECORD - $@: " . $marcresults->[$i];
1705
            warn "ERROR DECODING RECORD - $@: " . $marcresults->[$i];
1707
            next;
1706
            next;
(-)a/catalogue/search.pl (-1 / +1 lines)
Lines 660-666 for (my $i=0;$i<@servers;$i++) { Link Here
660
    elsif ($server =~/authorityserver/) { # this is the local authority server
660
    elsif ($server =~/authorityserver/) { # this is the local authority server
661
        my @inner_sup_results_array;
661
        my @inner_sup_results_array;
662
        for my $sup_record ( @{$results_hashref->{$server}->{"RECORDS"}} ) {
662
        for my $sup_record ( @{$results_hashref->{$server}->{"RECORDS"}} ) {
663
            my $marc_record_object = MARC::Record->new_from_usmarc($sup_record);
663
            my $marc_record_object = MARC::Record->new_from_xml($sup_record,'UTF-8');
664
            # warn "Authority Found: ".$marc_record_object->as_formatted();
664
            # warn "Authority Found: ".$marc_record_object->as_formatted();
665
            push @inner_sup_results_array, {
665
            push @inner_sup_results_array, {
666
                'title' => $marc_record_object->field(100)->subfield('a'),
666
                'title' => $marc_record_object->field(100)->subfield('a'),
(-)a/circ/circulation.pl (-1 / +1 lines)
Lines 309-315 if ($barcode) { Link Here
309
            foreach my $hit ( @{$results} ) {
309
            foreach my $hit ( @{$results} ) {
310
                my $chosen =
310
                my $chosen =
311
                  TransformMarcToKoha( C4::Context->dbh,
311
                  TransformMarcToKoha( C4::Context->dbh,
312
                    MARC::Record->new_from_usmarc($hit) );
312
                    MARC::Record->new_from_xml($hit,'UTF-8') );
313
313
314
                # offer all barcodes individually
314
                # offer all barcodes individually
315
                foreach my $barcode ( sort split(/\s*\|\s*/, $chosen->{barcode}) ) {
315
                foreach my $barcode ( sort split(/\s*\|\s*/, $chosen->{barcode}) ) {
(-)a/t/db_dependent/Search.t (-21 / +20 lines)
Lines 346-392 sub run_marc21_search_tests { Link Here
346
346
347
    ( undef, $results_hashref, $facets_loop ) =
347
    ( undef, $results_hashref, $facets_loop ) =
348
        getRecords('salud', 'salud', [], [ 'biblioserver' ], '19', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
348
        getRecords('salud', 'salud', [], [ 'biblioserver' ], '19', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
349
    ok(MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0])->title_proper() =~ m/^Efectos del ambiente/ &&
349
    ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() =~ m/^Efectos del ambiente/ &&
350
        MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[7])->title_proper() eq 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies' &&
350
        MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[7],'UTF-8')->title_proper() eq 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies' &&
351
        MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[18])->title_proper() =~ m/^Indicadores de resultados identificados/
351
        MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() =~ m/^Indicadores de resultados identificados/
352
        , "Simple relevance sorting in getRecords matches old behavior");
352
        , "Simple relevance sorting in getRecords matches old behavior");
353
353
354
    ( undef, $results_hashref, $facets_loop ) =
354
    ( undef, $results_hashref, $facets_loop ) =
355
        getRecords('salud', 'salud', [ 'author_az' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
355
        getRecords('salud', 'salud', [ 'author_az' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
356
    ok(MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0])->title_proper() =~ m/la enfermedad laboral\^ies$/ &&
356
    ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() =~ m/la enfermedad laboral\^ies$/ &&
357
        MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[6])->title_proper() =~ m/^Indicadores de resultados identificados/ &&
357
        MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[6],'UTF-8')->title_proper() =~ m/^Indicadores de resultados identificados/ &&
358
        MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[18])->title_proper() eq 'World health statistics 2009^ien'
358
        MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() eq 'World health statistics 2009^ien'
359
        , "Simple ascending author sorting in getRecords matches old behavior");
359
        , "Simple ascending author sorting in getRecords matches old behavior");
360
360
361
    ( undef, $results_hashref, $facets_loop ) =
361
    ( undef, $results_hashref, $facets_loop ) =
362
        getRecords('salud', 'salud', [ 'author_za' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
362
        getRecords('salud', 'salud', [ 'author_za' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
363
    ok(MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0])->title_proper() eq 'World health statistics 2009^ien' &&
363
    ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() eq 'World health statistics 2009^ien' &&
364
        MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[12])->title_proper() =~ m/^Indicadores de resultados identificados/ &&
364
        MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[12],'UTF-8')->title_proper() =~ m/^Indicadores de resultados identificados/ &&
365
        MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[18])->title_proper() =~ m/la enfermedad laboral\^ies$/
365
        MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() =~ m/la enfermedad laboral\^ies$/
366
        , "Simple descending author sorting in getRecords matches old behavior");
366
        , "Simple descending author sorting in getRecords matches old behavior");
367
367
368
    ( undef, $results_hashref, $facets_loop ) =
368
    ( undef, $results_hashref, $facets_loop ) =
369
        getRecords('salud', 'salud', [ 'pubdate_asc' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
369
        getRecords('salud', 'salud', [ 'pubdate_asc' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
370
    ok(MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0])->title_proper() eq 'Manual de higiene industrial^ies' &&
370
    ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() eq 'Manual de higiene industrial^ies' &&
371
        MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[7])->title_proper() =~ m/seguridad e higiene del trabajo\^ies$/ &&
371
        MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[7],'UTF-8')->title_proper() =~ m/seguridad e higiene del trabajo\^ies$/ &&
372
        MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[18])->title_proper() =~ m/^Indicadores de resultados identificados/
372
        MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() =~ m/^Indicadores de resultados identificados/
373
        , "Simple ascending publication date sorting in getRecords matches old behavior");
373
        , "Simple ascending publication date sorting in getRecords matches old behavior");
374
374
375
    ( undef, $results_hashref, $facets_loop ) =
375
    ( undef, $results_hashref, $facets_loop ) =
376
        getRecords('salud', 'salud', [ 'pubdate_dsc' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
376
        getRecords('salud', 'salud', [ 'pubdate_dsc' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
377
    ok(MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0])->title_proper() =~ m/^Estado de salud/ &&
377
    ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() =~ m/^Estado de salud/ &&
378
        MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[7])->title_proper() eq 'World health statistics 2009^ien' &&
378
        MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[7],'UTF-8')->title_proper() eq 'World health statistics 2009^ien' &&
379
        MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[18])->title_proper() eq 'Manual de higiene industrial^ies'
379
        MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() eq 'Manual de higiene industrial^ies'
380
        , "Simple descending publication date sorting in getRecords matches old behavior");
380
        , "Simple descending publication date sorting in getRecords matches old behavior");
381
381
TODO: {
382
    local $TODO = "Switch relevance search to MARCXML too";
382
    ( undef, $results_hashref, $facets_loop ) =
383
    ( undef, $results_hashref, $facets_loop ) =
383
        getRecords('books', 'books', [ 'relevance' ], [ 'biblioserver' ], '20', 0, undef, \%branches, \%itemtypes, undef, 1);
384
        getRecords('books', 'books', [ 'relevance' ], [ 'biblioserver' ], '20', 0, undef, \%branches, \%itemtypes, undef, 1);
384
    $record = MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0]);
385
    $record = MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0]);
385
    is($record->title_proper(), 'books', "Scan returned requested item");
386
    is($record->title_proper(), 'books', "Scan returned requested item");
386
    is($record->subfield('100', 'a'), 2, "Scan returned correct number of records matching term");
387
    is($record->subfield('100', 'a'), 2, "Scan returned correct number of records matching term");
387
388
    # Time to test buildQuery and searchResults too.
388
    # Time to test buildQuery and searchResults too.
389
389
}
390
    my ( $query, $simple_query, $query_cgi,
390
    my ( $query, $simple_query, $query_cgi,
391
    $query_desc, $limit, $limit_cgi, $limit_desc,
391
    $query_desc, $limit, $limit_cgi, $limit_desc,
392
    $stopwords_removed, $query_type );
392
    $stopwords_removed, $query_type );
Lines 526-535 sub run_marc21_search_tests { Link Here
526
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
526
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
527
    is($results_hashref->{biblioserver}->{hits}, 19, "Weighted query returned correct number of results");
527
    is($results_hashref->{biblioserver}->{hits}, 19, "Weighted query returned correct number of results");
528
    if ($indexing_mode eq 'grs1') {
528
    if ($indexing_mode eq 'grs1') {
529
        is(MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0])->title_proper(), 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies', "Weighted query returns best match first");
529
        is(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper(), 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies', "Weighted query returns best match first");
530
    } else {
530
    } else {
531
        local $TODO = "Query weighting does not behave exactly the same in DOM vs. GRS";
531
        local $TODO = "Query weighting does not behave exactly the same in DOM vs. GRS";
532
        is(MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0])->title_proper(), 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies', "Weighted query returns best match first");
532
        is(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper(), 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies', "Weighted query returns best match first");
533
    }
533
    }
534
534
535
    $QueryStemming = $QueryWeightFields = $QueryFuzzy = $QueryRemoveStopwords = 0;
535
    $QueryStemming = $QueryWeightFields = $QueryFuzzy = $QueryRemoveStopwords = 0;
536
- 

Return to bug 11096