Skip to content

Conversation

@Siva-Sai22
Copy link
Contributor

@Siva-Sai22 Siva-Sai22 commented Dec 8, 2025

Closes #14421

Implemented web search capability for ScienceDirect by integrating the Scopus Search API, since the ScienceDirect Search API requires institutional access that most users don't have. Added a new ScopusQueryTransformer to convert JabRef search queries to Scopus query syntax, and wrote the Scopus class to implement PagedSearchBasedParserFetcher interface, enabling paginated search results with proper JSON response parsing, this allows users to search academic literature via the "Web search" feature in JabRef, which was previously not available for ScienceDirect.
Modified the ScienceDirect to use the api key of scopus.

Steps to test

  • Go to settings -> preferences -> websearch.
  • Add the Scopus API key and test it.
  • Then search using the Scopus (Example query: author = Einstein)
Screenshot_20251220_002434 Screenshot_20251220_002153

Mandatory checks

@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2025

Hey @Siva-Sai22! 👋

Thank you for contributing to JabRef!

We have automated checks in place, based on which you will soon get feedback if any of them are failing.

After all automated checks pass, a maintainer will also review your contribution. Once that happens, you can go through their comments in the "Files changed" tab and act on them, or reply to the conversation if you have further inputs.

Please re-check our AI Usage Policy to ensure that your pull request is in line with it. It also contains links to our contribution guide in case of any other doubts related to our contribution workflow.

@Siva-Sai22 Siva-Sai22 changed the title Fix/#14421 feat(fetcher): implement SearchBasedFetcher for ScienceDirect using scopus search API Dec 8, 2025
@github-actions github-actions bot added status: changes-required Pull requests that are not yet complete and removed status: changes-required Pull requests that are not yet complete labels Dec 8, 2025
Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://dev.elsevier.com/technical_documentation.html Scopus is not ScienceDirect.

I see two options:

  1. To avoid confusion, ScienceDirect should be renamed to Elsevier. But then, we have a "big ball of mud", because the methods in that class are not coupled, but only semnatically correlated
  2. Add new functionality to Scopus - this should make maintainence easier. This fetcher should be added to the list of fetchers in the "Web Search" prefernces

Please do option 2 to have the fetcher class small.

  • API key should renamed from "Scopus" to "Esevier", since it covers both.

Future work: Split up API key configuration and fetcher enablement.

grafik

@github-actions github-actions bot added the status: changes-required Pull requests that are not yet complete label Dec 8, 2025
Siedlerchr
Siedlerchr previously approved these changes Dec 8, 2025
@Siedlerchr Siedlerchr added status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers and removed status: changes-required Pull requests that are not yet complete labels Dec 8, 2025
Comment on lines 227 to 231
String response = new BufferedReader(new InputStreamReader(inputStream))
.lines()
.collect(Collectors.joining(OS.NEWLINE));

JSONObject jsonObject = new JSONObject(response);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There must be a method to convert an inputstream to a JSON object directly. But maybe, not mit dem JSONObject.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

** JSONObject response = JsonReader.toJsonObject(inputStream);
**

@koppor
Copy link
Member

koppor commented Dec 8, 2025

Another view - from

grafik

@koppor koppor added status: changes-required Pull requests that are not yet complete and removed status: devcall status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers labels Dec 8, 2025
@Siva-Sai22
Copy link
Contributor Author

Siva-Sai22 commented Dec 9, 2025

  • API key should renamed from "Scopus" to "Esevier", since it covers both.

@koppor
But the ScienceDirect is accessing the api key using the FETCHER_NAME (ScienceDirect). If we rename it to Esevier we have to change the fetcher name also
importerPreferences.getApiKey(getName())

I think it would be better to take a scopus api key also.

@koppor
Copy link
Member

koppor commented Dec 11, 2025

  • API key should renamed from "Scopus" to "Esevier", since it covers both.

@koppor But the ScienceDirect is accessing the api key using the FETCHER_NAME (ScienceDirect). If we rename it to Esevier we have to change the fetcher name also importerPreferences.getApiKey(getName())

I think it would be better to take a scopus api key also.

I searched for the code you gave

image

It seems that EACH FETCHER uses that thing.

Since the new fetcher is a SearchBasedFetcher displayed in the preferences, the old fetcher should use the key of the other fetcher. With that, both fetchers will share the same key and it can be configured.

Update That means, my idea with "Elsevier" was wrong and a concrete fetcher name is used. -- Please double check with the preferences code.

@Siva-Sai22
Copy link
Contributor Author

@koppor I have checked the preferences code
The api key is stored in a keyring and retrieved using the same when called using the concrete fetcher name
So I think we can't have the same api key name for the two different fetchers.

I have changes in which we allow the user to input the api key for scopus (same as the scienceDirect one) and can display the search results.

If you are okay with this approach I will update the PR.

@github-actions
Copy link
Contributor

Your pull request conflicts with the target branch.

Please merge with your code. For a step-by-step guide to resolve merge conflicts, see https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line.

@koppor
Copy link
Member

koppor commented Dec 17, 2025

@Siva-Sai22 It is difficult for me to follow. Please provide a link (you can search for files on GitHub by typing T). Provide a deep link to the line number. - It is also OK to provide a class name and line number. Answers might then even take longer, since we mostly do JabRef during the day in short breaks without an IDE opened.

@koppor
Copy link
Member

koppor commented Dec 17, 2025

I have changes in which we allow the user to input the api key for scopus (same as the scienceDirect one) and can display the search results.

No, this is not OK, because it seems that only one fetcher is displayed and not the other one.


To move on, you extract your new SearchBasedFetcher out and revert the original class to their own state. Then we maybe see easier how the key handling works.

@Siva-Sai22
Copy link
Contributor Author

Siva-Sai22 commented Dec 18, 2025

@koppor

So the keys are fetched using the fetcher name.
The method you discussed above:

API key should renamed from "Scopus" to "Esevier", since it covers both.

This cannot be done because the api key is fetched using fetcher name.

As suggested by you the scienceDirect should be kept as it is (and not make it a search based fetcher) and instead make a new searchbasedfetcher known as Scopus which uses the Esevier's api for searching.

The scienceDirect and this scopus one will use the same api key. But inorder to use these the user has to put in the same api key twice (one for using scienceDirect which is fulltextFetcher (not modified) and one for the new Scopus which is searchBasedFetcher)

These are the changes : main...Siva-Sai22:jabref:test

@koppor koppor added status: waiting-for-feedback The submitter or other users need to provide more information about the issue and removed status: changes-required Pull requests that are not yet complete labels Dec 18, 2025
@github-actions github-actions bot added the status: changes-required Pull requests that are not yet complete label Dec 19, 2025
@koppor
Copy link
Member

koppor commented Dec 19, 2025

@Siva-Sai22 I seee that the class ScienceDirect itself calls the api key. One can replace getName() by Elsevier.

@koppor koppor added 📌 Pinned and removed status: waiting-for-feedback The submitter or other users need to provide more information about the issue labels Dec 19, 2025
@Siva-Sai22
Copy link
Contributor Author

Siva-Sai22 commented Dec 20, 2025

@koppor For the tests I thought that if they covered the cases correctly then it is enough. So generated it through ai by explaining it the cases and focused more on the actual implementation. Sorry for that, next time onwards will write the tests also myself.

Siva-Sai22 and others added 6 commits December 20, 2025 16:02
…pdate related tests and docs

- Use Scopus API key for ScienceDirect fetcher and remove separate ScienceDirect API key handling
- Update environment variable and build configuration to use ScopusApiKey
- Adjust tests to reflect unified API key usage
- Remove redundant or obsolete test cases in Scopus and query transformer tests
- Update documentation and changelog to clarify Scopus/ScienceDirect API key requirements
…pdate related tests and docs

- Use Scopus API key for ScienceDirect fetcher and remove separate ScienceDirect API key handling
- Update environment variable and build configuration to use ScopusApiKey
- Adjust tests to reflect unified API key usage
- Remove redundant or obsolete test cases in Scopus and query transformer tests
- Update documentation and changelog to clarify Scopus/ScienceDirect API key requirements

# Conflicts:
#	jablib/src/main/java/org/jabref/logic/importer/fetcher/ScienceDirect.java
@github-actions github-actions bot added status: changes-required Pull requests that are not yet complete and removed status: changes-required Pull requests that are not yet complete labels Dec 20, 2025
Comment on lines 37 to 38
* Note: ScienceDirect Search API requires institutional access, so we use Scopus API instead
* which is available to all registered developers.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure? I think, it is different functionalit!!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I tried using the same api key from elsevier to the scienceDirect api. It always returned authorization error.

{"status":{"statusCode":"AUTHORIZATION_ERROR","statusText":"The requestor is not authorized to access the requested view or fields of the resource"}}}

https://www.elsevier.support/dataasaservice/answer/why-do-i-receive-error-responses-saying-some-api-resources-are-unauthorized-or-that-i-have-insufficient-privileges

@github-actions github-actions bot removed the status: changes-required Pull requests that are not yet complete label Dec 26, 2025
Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if you have the energy to have a good java doc and fix other small nitpicks.

It is OK to say: no time - then someone of the team will try to finish.

Comment on lines 5 to 18
/**
* Query transformer for the Scopus Search API.
* <p>
* Scopus uses specific field codes for advanced search:
* - TITLE-ABS-KEY-AUTH() for searching in title, abstract, author and keywords
* - AUTH() for author search
* - SRCTITLE() for journal/source title search
* - PUBYEAR for publication year
* - DOI() for DOI search
* <p>
* Scopus supports AND, OR, AND NOT as boolean operators.
* <p>
* See: https://dev.elsevier.com/sc_search_tips.html
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convert to markdown - or use proper HTML - the item list is not correctly displayed as is.

Comment on lines 177 to 178
@Nullable
private BibEntry parseScopusEntry(JSONObject jsonEntry) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In JabRef, we use Optionals.

@github-actions github-actions bot added the status: changes-required Pull requests that are not yet complete label Dec 27, 2025
@github-actions github-actions bot removed the status: changes-required Pull requests that are not yet complete label Dec 28, 2025
@Siva-Sai22
Copy link
Contributor Author

@koppor updated the pr with required changes. Please let me know if any other changes are required.

@github-actions github-actions bot added the status: changes-required Pull requests that are not yet complete label Dec 29, 2025
@github-actions github-actions bot added status: changes-required Pull requests that are not yet complete and removed status: changes-required Pull requests that are not yet complete labels Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: fetcher first contrib good second issue Issues that involve a tour of two or three interweaved components in JabRef 📌 Pinned status: changes-required Pull requests that are not yet complete

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make ScienceDirect a SearchBasedFetcher to be able to use an API key in the UI

4 participants