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

Add orcid fields to searches #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dennmuel
Copy link
Contributor

@dennmuel dennmuel commented May 20, 2019

Fixes #22
Wouldn't be mad if this doesn't get merged, I know it's not exactly a killer feature ;)
(Tagging @wfyson)

@dennmuel
Copy link
Contributor Author

dennmuel commented Jul 18, 2019

I'm having a small problem with this.... The orcid fields get added to the search form, however it is not possible to search for multiple values separated by a blank (like it is e.g. for the creators/editors/contributors name field).

Both values are present in the query, like so:
&creators_orcid%2Feditors_orcid=0000-0002-6485-9434+0000-0002-7476-704X)

But the result only takes the first one into account. If I go back to refine the search, the second ORCID has disappeared from the search field. How can I make the orcid search fields behave like the name field in this regard?

@wfyson
Copy link
Collaborator

wfyson commented Jul 18, 2019

I think to fix that we'd need to adapt how Metafield/Orcid.pm works possibly...

Because when searching for ORCIDs you want to match the whole ORCID (i.e. you don't want anything that matches part of the ORCID), we have to treat the ORCID field as an 'id' field which only matches search strings exactly. We'd need to adapt this to treat space separated values as multiple values.

However, I'm not sure precisely how to go about this unfortunately, it is something that will need looking into!

@dennmuel
Copy link
Contributor Author

Thanks for the quick reply! I'll have a look at Orcid.pm and see if I can figure it out. :)

@dennmuel
Copy link
Contributor Author

dennmuel commented Jul 19, 2019

Well, I managed to change the match and merge values by simply adding this:

sub get_property_defaults
{
        my( $self ) = @_;
        my %defaults = $self->SUPER::get_property_defaults;
        $defaults{match} = "IN";
        $defaults{merge} = "ANY";
        return %defaults;
}

And loop through the values to validate each given id:

sub from_search_form
{
    my( $self, $session, $prefix ) = @_;

    my $val = $session->param( $prefix );
    return $val unless EPrints::Utils::is_set( $val );

    my @values = split / /, $val;
    my @bits;
    foreach my $v (@values){
        if( $v = EPrints::ORCID::Utils::get_normalised_orcid( $v ) )
        {
            push @bits, $v;
        }
    }

    if(scalar @bits != 0){
        return(
            $session->make_text( join( ' ', @bits) ),
            scalar($session->param( $prefix."_match" )),
            scalar($session->param( $prefix."_merge" ))
        );
    }

        return( undef,undef,undef, $session->html_phrase( "searchfield:orcid_err" ) );
}

But now the search doesn't return any hits :/ Any idea where I'm going wrong?

(Out of curiosity: Is there a way to distinct how the field behaves depending on whether it's a search for an eprint or a user? For a user, the orcid id serves as an identifier, but for an eprint it doesn't.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add orcid to eprint and user search
2 participants