From: miker Date: Fri, 26 Mar 2010 02:52:58 +0000 (+0000) Subject: add alias mapping table and QueryParser support -- particularly important for SRU X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=5d5398534cc2c8b5687d26fc2c5bc2832dc7b226;p=evergreen%2Fbjwebb.git add alias mapping table and QueryParser support -- particularly important for SRU git-svn-id: svn://svn.open-ils.org/ILS/trunk@16000 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index c35ea0dbc..1fe8b2720 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -1464,6 +1464,26 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + + + + + + + + + + + + + + + + + + + diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm index da900d9e3..843a739d2 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm @@ -197,6 +197,22 @@ sub initialize_search_field_id_map { return $self->search_field_id_map; } +sub initialize_aliases { + my $self = shift; + my $cmsa_list = shift; + + for my $cmsa (@$cmsa_list) { + if (!$cmsa->field) { + __PACKAGE__->add_search_class_alias( $cmsa->field_class, $cmsa->alias ); + } else { + my $c = $self->search_field_class_by_id( $cmsa->field ); + __PACKAGE__->add_search_field_alias( $cmsa->field_class, $c->{field}, $cmsa->alias ); + } + } + + return $self->relevance_bumps; +} + sub initialize_relevance_bumps { my $self = shift; my $sra_list = shift; @@ -233,6 +249,9 @@ sub initialize { $self->initialize_search_field_id_map( $args{config_metabib_field} ) if ($args{config_metabib_field}); + $self->initialize_aliases( $args{config_metabib_search_alias} ) + if ($args{config_metabib_search_alias}); + $self->initialize_relevance_bumps( $args{search_relevance_adjustment} ) if ($args{search_relevance_adjustment}); @@ -242,6 +261,7 @@ sub initialize { $_complete = 1 if ( $args{config_metabib_field_index_norm_map} && $args{search_relevance_adjustment} && + $args{config_metabib_search_alias} && $args{config_metabib_field} ); diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/metabib.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/metabib.pm index 59718ddb8..9d3d37b25 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/metabib.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/metabib.pm @@ -2784,6 +2784,11 @@ sub query_parser_fts { 'open-ils.cstore.direct.config.metabib_field.search.atomic', { id => { "!=" => undef } } )->gather(1), + config_metabib_search_alias => + $cstore->request( + 'open-ils.cstore.direct.config.metabib_search_alias.search.atomic', + { id => { "!=" => undef } } + )->gather(1), ); $cstore->disconnect; diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index f22a9b9e7..fc7ef99c4 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -59,7 +59,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0214'); -- Scott McKellar +INSERT INTO config.upgrade_log (version) VALUES ('0215'); -- Scott McKellar CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, @@ -233,6 +233,12 @@ $$; CREATE UNIQUE INDEX config_metabib_field_class_name_idx ON config.metabib_field (field_class, name); +CREATE TABLE config.metabib_search_alias ( + alias TEXT PRIMARY KEY, + field_class TEXT NOT NULL REFERENCES config.metabib_class (name), + field INT REFERENCES config.metabib_field (id) +); + CREATE TABLE config.non_cataloged_type ( id SERIAL PRIMARY KEY, owning_lib INT NOT NULL, -- REFERENCES actor.org_unit (id), diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 3eabf7487..3d5abc934 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -53,6 +53,50 @@ INSERT INTO config.metabib_field (field_class, name, label, format, xpath ) VALU (16, 'subject', 'complete', oils_i18n_gettext(16, 'All Subjects', 'cmf', 'label'), 'mods32', $$//mods32:mods/mods32:subject//text()$$ ); SELECT SETVAL('config.metabib_field_id_seq'::TEXT, (SELECT MAX(id) FROM config.metabib_field), TRUE); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('kw','keyword'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('eg.keyword','keyword'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('dc.publisher','keyword'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('dc.identifier','keyword'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('bib.subjecttitle','keyword'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('bib.genre','keyword'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('bib.edition','keyword'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('srw.serverchoice','keyword'); + +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('au','author'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('name','author'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('creator','author'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('eg.author','author'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('eg.name','author'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('dc.creator','author'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('dc.contributor','author'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('bib.name','author'); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.namepersonal','author',8); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.namepersonalfamily','author',8); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.namepersonalgiven','author',8); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.namecorporate','author',7); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.nameconference','author',9); + +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('ti','title'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('eg.title','title'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('dc.title','title'); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.titleabbreviated','title',2); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.titleuniform','title',5); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.titletranslated','title',3); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.titlealternative','title',4); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.title','title',2); + +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('su','subject'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('eg.subject','subject'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('dc.subject','subject'); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.subjectplace','subject',11); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.subjectname','subject',12); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.subjectoccupation','subject',16); + +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('se','series'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('eg.series','series'); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.titleseries','series',1); + + INSERT INTO config.non_cataloged_type ( id, owning_lib, name ) VALUES ( 1, 1, oils_i18n_gettext(1, 'Paperback Book', 'cnct', 'name') ); SELECT SETVAL('config.non_cataloged_type_id_seq'::TEXT, 100); diff --git a/Open-ILS/src/sql/Pg/upgrade/0215.schema.search_aliases.sql b/Open-ILS/src/sql/Pg/upgrade/0215.schema.search_aliases.sql new file mode 100644 index 000000000..af97f7db5 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0215.schema.search_aliases.sql @@ -0,0 +1,57 @@ +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0215'); -- miker + + +CREATE TABLE config.metabib_search_alias ( + alias TEXT PRIMARY KEY, + field_class TEXT NOT NULL REFERENCES config.metabib_class (name), + field INT REFERENCES config.metabib_field (id) +); + + +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('kw','keyword'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('eg.keyword','keyword'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('dc.publisher','keyword'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('dc.identifier','keyword'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('bib.subjecttitle','keyword'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('bib.genre','keyword'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('bib.edition','keyword'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('srw.serverchoice','keyword'); + +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('au','author'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('name','author'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('creator','author'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('eg.author','author'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('eg.name','author'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('dc.creator','author'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('dc.contributor','author'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('bib.name','author'); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.namepersonal','author',8); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.namepersonalfamily','author',8); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.namepersonalgiven','author',8); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.namecorporate','author',7); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.nameconference','author',9); + +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('ti','title'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('eg.title','title'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('dc.title','title'); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.titleabbreviated','title',2); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.titleuniform','title',5); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.titletranslated','title',3); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.titlealternative','title',4); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.title','title',2); + +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('su','subject'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('eg.subject','subject'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('dc.subject','subject'); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.subjectplace','subject',11); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.subjectname','subject',12); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.subjectoccupation','subject',16); + +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('se','series'); +INSERT INTO config.metabib_search_alias (alias,field_class) VALUES ('eg.series','series'); +INSERT INTO config.metabib_search_alias (alias,field_class,field) VALUES ('bib.titleseries','series',1); + +COMMIT; +