Backport SRU fixes from trunk (r19572, r19573)
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 4 Mar 2011 04:58:41 +0000 (04:58 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 4 Mar 2011 04:58:41 +0000 (04:58 +0000)
Add complete set of Evergreen search aliases and attributes to SRU explain

Original "pull from database" code had limited the search aliases to those
that were qualified; now we pull all of them, and if they are not qualified,
we qualify them as "eg".

In addition, for some of the non-index attributes (sort, direction, site,
available), restore the descriptive title that was previously available.
Slightly longer term we will add a "description" column to
config.metabib_search_alias to store this information.

By returning explicit index and title elements from the method,
we can backport cleanly to 2.0 and set the stage for pulling the
title element directly from the database in 2.1 and beyond.

In addition, the enriched object enables us to get rid of the
hardcoded nested qualifier map for bibs.

Finally, we also fix the mappings of SRU qualifiers to Evergreen
search aliases (in many cases we had been quietly falling back
to plain kw searches, which was not cool).

git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_2_0@19576 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm
Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm

index ac5b0f9..a7e37d3 100644 (file)
@@ -2822,12 +2822,20 @@ sub return_bib_search_aliases {
 
        my $cmsa = $_storage->request(
                'open-ils.cstore.direct.config.metabib_search_alias.search.atomic',
-               { alias => { like => '%.%'} }
+               { alias => { '!=' => undef } }
        )->gather(1);
 
-    foreach my $alias (@$cmsa) {
-        my ($qualifier, $name) = $alias->alias =~ m/^(.+?)\.(.+)$/;
-        push(@{$aliases{$qualifier}}, $name);
+    foreach (@$cmsa) {
+        if ($_->alias =~ /\./) {
+            my ($qualifier, $name) = $_->alias =~ m/^(.+?)\.(.+)$/;
+            $aliases{$qualifier}{$name}{'index'} = $_->alias;
+            # We will add a 'title' property in a subsequent schema
+            $aliases{$qualifier}{$name}{'title'} = $name;
+        } else {
+            # au/kw/se/su/ti go into the default 'eg' qualifier
+            $aliases{'eg'}{$_->alias}{'index'} = $_->alias;
+            $aliases{'eg'}{$_->alias}{'title'} = $_->alias;
+        }
     }
 
     return \%aliases;
index 3d9b87f..19c5b75 100644 (file)
@@ -147,6 +147,41 @@ sub child_init {
         ->request("open-ils.supercat.biblio.search_aliases")
         ->gather(1)};
 
+    my %attribute_desc = (
+        site        => 'Evergreen Site Code (shortname)',
+        sort        => 'Sort on relevance, title, author, pubdate, create_date or edit_date',
+        dir         => 'Sort direction (asc|desc)',
+        available   => 'Filter to available (true|false)',
+    );
+
+    # Append the non-search-alias attributes to the qualifier map
+    foreach ( qw/
+        available
+        ascending
+        descending
+        sort
+        format
+        before
+        after
+        statuses
+        locations
+        site
+        depth
+        lasso
+        offset
+        limit
+        preferred_language
+        preferred_language_weight
+        preferred_language_multiplier
+     /) {
+        $qualifier_map{'eg'}{$_}{'index'} = $_;
+        if (exists $attribute_desc{$_}) {
+            $qualifier_map{'eg'}{$_}{'title'} = $attribute_desc{$_};
+        } else {
+            $qualifier_map{'eg'}{$_}{'title'} = $_;
+        }
+    }
+
        my $list = $supercat
                ->request("open-ils.supercat.record.formats")
                ->gather(1);
@@ -1612,88 +1647,6 @@ our %qualifier_ids = (
                srw     => ''
 );
 
-our %nested_qualifier_map = (
-               eg => {
-                       site            => ['site','Evergreen Site Code (shortname)'],
-                       sort            => ['sort','Sort on relevance, title, author, pubdate, create_date or edit_date'],
-                       direction       => ['dir','Sort direction (asc|desc)'],
-                       available       => ['available','Filter to available (true|false)'],
-                       title           => ['title'],
-                       author          => ['author'],
-                       name            => ['author'],
-                       subject         => ['subject'],
-                       keyword         => ['keyword'],
-                       series          => ['series'],
-               },
-               dc => {
-                       title           => ['title'],
-                       creator         => ['author'],
-                       contributor     => ['author'],
-                       publisher       => ['keyword'],
-                       subject         => ['subject'],
-                       identifier      => ['keyword'],
-                       type            => [undef],
-                       format          => [undef],
-                       language        => ['lang'],
-               },
-               bib => {
-               # Title class:
-               titleAbbreviated        => ['title'],
-                   titleUniform                => ['title'],
-                       titleTranslated         => ['title'],
-               titleAlternative        => ['title'],
-                   titleSeries                 => ['series'],
-
-    # Author/Name class:
-                       name                            => ['author'],
-                       namePersonal            => ['author'],
-                       namePersonalFamily      => ['author'],
-                       namePersonalGiven       => ['author'],
-                       nameCorporate           => ['author'],
-                       nameConference          => ['author'],
-
-               # Subject class:
-                       subjectPlace            => ['subject'],
-                       subjectTitle            => ['keyword'],
-                       subjectName                     => ['subject|name'],
-                       subjectOccupation       => ['keyword'],
-
-    # Keyword class:
-
-    # Dates:
-                       dateIssued                      => [undef],
-                       dateCreated                     => [undef],
-                       dateValid                       => [undef],
-                       dateModified            => [undef],
-                       dateCopyright           => [undef],
-
-    # Genre:
-                       genre                           => ['keyword'],
-
-    # Target Audience:
-                       audience                        => [undef],
-
-    # Place of Origin:
-                       originPlace                     => [undef],
-
-    # Edition
-                       edition                         => ['keyword'],
-
-    # Part:
-                       volume                          => ['keyword'],
-                       issue                           => ['keyword'],
-                       startPage                       => ['keyword'],
-                       endPage                         => ['keyword'],
-
-    # Issuance:
-                       issuance                        => ['keyword'],
-               },
-               srw     => {
-                       serverChoice            => ['keyword'],
-               },
-);
-
-
 my $base_explain = <<XML;
 <explain
                id="evergreen-sru-explain-full"
@@ -1860,7 +1813,7 @@ sub sru_search {
                        $e->findnodes('/z:explain/z:serverInfo/z:port')->shift->appendText( $cgi->server_port );
                        $e->findnodes('/z:explain/z:serverInfo/z:database')->shift->appendText( $url );
 
-                       for my $name ( keys %OpenILS::WWW::SuperCat::nested_qualifier_map ) {
+                       for my $name ( keys %qualifier_map ) {
 
                                my $identifier = $OpenILS::WWW::SuperCat::qualifier_ids{ $name };
 
@@ -1871,8 +1824,8 @@ sub sru_search {
                                $set_node->setAttribute( name => $name );
 
                                $e->findnodes('/z:explain/z:indexInfo')->shift->appendChild( $set_node );
-
-                               for my $index ( @{$qualifier_map{$name} } ) {
+                               for my $index ( sort keys %{$qualifier_map{$name} } ) {
                                        my $name_node = $doc->createElementNS( 'http://explain.z3950.org/dtd/2.0/', 'name' );
 
                                        my $map_node = $doc->createElementNS( 'http://explain.z3950.org/dtd/2.0/', 'map' );
@@ -1885,9 +1838,9 @@ sub sru_search {
                                        $index_node->appendChild( $map_node );
 
                                        $index_node->setAttribute( id => "$name.$index" );
-                                       $title_node->appendText( $index);
+                                       $title_node->appendText($qualifier_map{$name}{$index}{'title'});
                                        $name_node->setAttribute( set => $name );
-                                       $name_node->appendText($index);
+                                       $name_node->appendText($qualifier_map{$name}{$index}{'index'});
 
                                        $e->findnodes('/z:explain/z:indexInfo')->shift->appendChild( $index_node );
                                }
@@ -1938,10 +1891,9 @@ sub sru_search {
         if ( $qualifier ) {
                        my ($qset, $qname) = split(/\./, $qualifier);
 
-                       $log->debug("SRU toEvergreen: $qset, $qname   $OpenILS::WWW::SuperCat::nested_qualifier_map{$qset}{$qname}[0]\n");
-
-            if ( exists($OpenILS::WWW::SuperCat::nested_qualifier_map{$qset}{$qname}) ) {
-                $qualifier = $OpenILS::WWW::SuperCat::nested_qualifier_map{$qset}{$qname}[0] || 'kw';
+            if ( exists($qualifier_map{$qset}{$qname}) ) {
+                $qualifier = $qualifier_map{$qset}{$qname}{'index'} || 'kw';
+                $log->debug("SRU toEvergreen: $qset, $qname   $qualifier_map{$qset}{$qname}{'index'}\n");
                        }
 
             my @modifiers = $relation->getModifiers();