Skip to content

Add sort argument to the search API 🔍#4865

Merged
vladak merged 5 commits intooracle:masterfrom
gaborbernat:4740-feat
Jan 5, 2026
Merged

Add sort argument to the search API 🔍#4865
vladak merged 5 commits intooracle:masterfrom
gaborbernat:4740-feat

Conversation

@gaborbernat
Copy link
Copy Markdown
Contributor

@gaborbernat gaborbernat commented Oct 2, 2025

Fixes #4740

Adds a sort parameter to the search API that allows clients to control result ordering:

  • relevancy (default) - Results ranked by Lucene score
  • lastmodtime - Results ordered by file modification date (newest first)
  • fullpath - Results ordered alphabetically by file path

The implementation uses Lucene 9's TopFieldCollectorManager API for sorted searches and TopScoreDocCollectorManager for relevancy-based searches.

📝 API documentation updated in apiary.apib
✅ Tests verify correct ordering for both LASTMODIFIED and BY_PATH sort modes

@oracle-contributor-agreement
Copy link
Copy Markdown

Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
The following contributors of this PR have not signed the OCA:

To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application.

When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated.

If you are an Oracle employee, please make sure that you are a member of the main Oracle GitHub organization, and your membership in this organization is public.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. label Oct 2, 2025
@vladak
Copy link
Copy Markdown
Member

vladak commented Oct 14, 2025

The Apirary documentation in the apiary.apib file needs update for the /search endpoint.

Comment thread opengrok-indexer/src/main/java/org/opengrok/indexer/search/SearchEngine.java Outdated
@vladak
Copy link
Copy Markdown
Member

vladak commented Oct 14, 2025

Also, needs a test case.

Comment thread opengrok-indexer/src/main/java/org/opengrok/indexer/search/SearchEngine.java Outdated
@vladak
Copy link
Copy Markdown
Member

vladak commented Oct 14, 2025

Just a note: this conflicts with the changes done for Lucene 9.x update in PR #4867. It looks like this can be reconciled easily, though.

@gaborbernat
Copy link
Copy Markdown
Contributor Author

I signed the OCA on Friday any idea when it will be approved?

@gaborbernat gaborbernat force-pushed the 4740-feat branch 10 times, most recently from 41ef174 to db9f5fa Compare October 16, 2025 02:39
@gaborbernat gaborbernat requested a review from vladak October 16, 2025 02:39
@gaborbernat gaborbernat force-pushed the 4740-feat branch 3 times, most recently from 35d7af4 to 8fd284e Compare October 16, 2025 14:25
@oracle-contributor-agreement
Copy link
Copy Markdown

Thank you for signing the OCA.

@oracle-contributor-agreement oracle-contributor-agreement bot added OCA Verified All contributors have signed the Oracle Contributor Agreement. and removed OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. labels Oct 16, 2025
@gaborbernat
Copy link
Copy Markdown
Contributor Author

@vladak when you can please take another look, thanks!

@vladak
Copy link
Copy Markdown
Member

vladak commented Oct 21, 2025

@vladak when you can please take another look, thanks!

The failing tests need to be fixed first.

@gaborbernat
Copy link
Copy Markdown
Contributor Author

I'd say add a copyright entry to each file with a non-trivial change.

Do I need to? How would this entry look like?

@vladak
Copy link
Copy Markdown
Member

vladak commented Dec 11, 2025

I'd say add a copyright entry to each file with a non-trivial change.

Do I need to? How would this entry look like?

I think it is not necessary. Such entry would look like this:

/*
 * ...
 * Portions Copyright (c) 2025, Your Name <your.email@example.com>.
 */

where the ... stand out for any pre-existing copyright entry. The e-mail is optional. Again, take a look at the example above.

@gaborbernat
Copy link
Copy Markdown
Contributor Author

I think it is not necessary.

If it's not necessary, I decide not to add it. No need for my name to be in this.

@gaborbernat gaborbernat marked this pull request as draft December 16, 2025 19:36
@vladak
Copy link
Copy Markdown
Member

vladak commented Dec 17, 2025

I think it is not necessary.

If it's not necessary, I decide not to add it. No need for my name to be in this.

That's fine. Once you resolve the merge for the recent Lucene 9.x upgrade, this can go in.

@gaborbernat gaborbernat force-pushed the 4740-feat branch 2 times, most recently from 1dc9a01 to 5392c7e Compare January 3, 2026 01:47
@gaborbernat gaborbernat marked this pull request as ready for review January 3, 2026 03:19
@gaborbernat gaborbernat force-pushed the 4740-feat branch 4 times, most recently from c96651e to 47d7922 Compare January 3, 2026 03:57
@gaborbernat
Copy link
Copy Markdown
Contributor Author

@vladak should be ready to go.

@gaborbernat gaborbernat changed the title Add sort arugment for the search API Add sort argument to the search API 🔍 Jan 3, 2026
Signed-off-by: Bernát Gábor <gaborjbernat@gmail.com>
Signed-off-by: Bernát Gábor <gaborjbernat@gmail.com>
Signed-off-by: Bernát Gábor <gaborjbernat@gmail.com>
Signed-off-by: Bernát Gábor <gaborjbernat@gmail.com>
Signed-off-by: Bernát Gábor <gaborjbernat@gmail.com>
Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
@vladak vladak merged commit 7d04476 into oracle:master Jan 5, 2026
11 checks passed
@vladak
Copy link
Copy Markdown
Member

vladak commented Jan 5, 2026

Thanks for contribution and for the patience.

@gaborbernat gaborbernat deleted the 4740-feat branch January 5, 2026 14:42
@gaborbernat
Copy link
Copy Markdown
Contributor Author

Thanks, any plans when you would be able to cut a new release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Search API allow sort by path

2 participants