SRU: Restructure the hash returned from open-ils.supercat.biblio.search_aliases
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 4 Mar 2011 02:39:53 +0000 (02:39 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 4 Mar 2011 02:39:53 +0000 (02:39 +0000)
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, and also enables us to
fix the explain document for SRU for authority records.

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/trunk@19573 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index b9b3adf..f705d81 100644 (file)
@@ -2854,10 +2854,13 @@ sub return_bib_search_aliases {
     foreach (@$cmsa) {
         if ($_->alias =~ /\./) {
             my ($qualifier, $name) = $_->alias =~ m/^(.+?)\.(.+)$/;
-            push(@{$aliases{$qualifier}}, $name);
+            $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
-            push(@{$aliases{'eg'}}, $_->alias);
+            $aliases{'eg'}{$_->alias}{'index'} = $_->alias;
+            $aliases{'eg'}{$_->alias}{'title'} = $_->alias;
         }
     }
 
index 5debca7..9f4f183 100644 (file)
@@ -147,26 +147,40 @@ 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
-    push(@{$qualifier_map{'eg'}}, qw/
-        available
-        ascending
-        descending
-        sort
-        format
-        before
-        after
-        statuses
-        locations
-        site
-        depth
-        lasso
-        offset
-        limit
-        preferred_language
-        preferred_language_weight
-        preferred_language_multiplier
-    /);
+    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")
@@ -1633,97 +1647,16 @@ 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'],
-        },
-);
-
 # Our authority search options are currently pretty impoverished;
 # just right-truncated string match on a few categories, or by
 # ID number
 our %nested_auth_qualifier_map = (
         eg => {
-            id          => ['id', 'Record number'],
-            name        => ['author', 'Personal or corporate author, or meeting name'],
-            title       => ['title', 'Uniform title'],
-            subject     => ['subject', 'Chronological term, topical term, geographic name, or genre/form term'],
-            topic       => ['topic', 'Topical term'],
+            id          => { index => 'id', title => 'Record number'},
+            name        => { index => 'author', title => 'Personal or corporate author, or meeting name'},
+            title       => { index => 'title', title => 'Uniform title'},
+            subject     => { index => 'subject', title => 'Chronological term, topical term, geographic name, or genre/form term'},
+            topic       => { index => 'topic', title => 'Topical term'},
         },
 );
 
@@ -1926,10 +1859,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();
@@ -1970,10 +1902,9 @@ sub sru_search {
         if ( $qualifier ) {
             my ($qset, $qname) = split(/\./, $qualifier);
 
-            $log->debug("SRU toEvergreenAuth: $qset, $qname   $OpenILS::WWW::SuperCat::nested_auth_qualifier_map{$qset}{$qname}[0]\n");
-
             if ( exists($OpenILS::WWW::SuperCat::nested_auth_qualifier_map{$qset}{$qname}) ) {
-                $qualifier = $OpenILS::WWW::SuperCat::nested_auth_qualifier_map{$qset}{$qname}[0] || 'author';
+                $qualifier = $OpenILS::WWW::SuperCat::nested_auth_qualifier_map{$qset}{$qname}{'index'} || 'author';
+                $log->debug("SRU toEvergreenAuth: $qset, $qname   $OpenILS::WWW::SuperCat::nested_auth_qualifier_map{$qset}{$qname}{'index'}\n");
             }
         }
         return { qualifier => $qualifier, term => $term };
@@ -2041,19 +1972,7 @@ sub return_sru_explain {
             $set_node->setAttribute( name => $name );
 
             $e->findnodes('/z:explain/z:indexInfo')->shift->appendChild( $set_node );
-            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)',
-            );
-
-            for my $index ( @{$index_map->{$name}} ) {
-                my $title = $index;
-                if (exists $attribute_desc{$title}) {
-                    $title = $attribute_desc{$title};
-                }
-
+            for my $index ( sort keys %{$index_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' );
@@ -2066,9 +1985,9 @@ sub return_sru_explain {
                 $index_node->appendChild( $map_node );
 
                 $index_node->setAttribute( id => "$name.$index" );
-                $title_node->appendText($title);
+                $title_node->appendText($index_map->{$name}{$index}{'title'});
                 $name_node->setAttribute( set => $name );
-                $name_node->appendText($index);
+                $name_node->appendText($index_map->{$name}{$index}{'index'});
 
                 $e->findnodes('/z:explain/z:indexInfo')->shift->appendChild( $index_node );
             }