Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

virtual fields that return multiple values need to declare multiple=>1 #25

Open
drtjmb opened this issue Mar 24, 2015 · 0 comments
Open
Labels

Comments

@drtjmb
Copy link
Member

drtjmb commented Mar 24, 2015

...otherwise for example Xapian indexing fails (lib/cfg.d/search_xapian.pl) - an arrayref gets passed to the TermGenerator when a scalar is expected.

Workaround:

diff --git a/lib/cfg.d/search_xapian.pl b/lib/cfg.d/search_xapian.pl
index b2a923f..2fa6ece 100644
--- a/lib/cfg.d/search_xapian.pl
+++ b/lib/cfg.d/search_xapian.pl
@@ -81,6 +81,7 @@ $c->add_trigger( EP_TRIGGER_INDEX_FIELDS, sub {
                next if $field->isa( "EPrints::MetaField::Langid" );
                next if $field->isa( "EPrints::MetaField::Subobject" );
                next if $field->isa( "EPrints::MetaField::Storable" );
+               next if $field->is_virtual;

                my $prefix = $field->name . ':';
                my $value = $field->get_value( $dataobj );
@@ -97,7 +98,7 @@ $c->add_trigger( EP_TRIGGER_INDEX_FIELDS, sub {
                                $value = $v;
                        }
                        next if !EPrints::Utils::is_set( $value );
-                       $tg->index_text( $value );
+                       $tg->index_text( $value ); # or this will choke on virtual fields that have an arrayref value
                        $tg->increase_termpos();
                        next if length($value) > 200; # Xapian term length limit-ish
                        if( $field->isa( "EPrints::MetaField::Text" ) || $field->isa( "EPrints::MetaField::Name" ) )

@drtjmb drtjmb added the bug label Mar 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant