sonatype-nexus-community / search-maven-org

Apache License 2.0
478 stars 141 forks source link

REST API: Artifact versions are ordered by name, not by release date #147

Open Marcono1234 opened 3 years ago

Marcono1234 commented 3 years ago

What are you trying to do?

Get the latest version of an artifact using the REST API https://search.maven.org/solrsearch

It appears that artifact versions are ordered by name, not by release date. E.g. commons-io:commons-io has a version 20030203.000550 released in 2005, the latest version is currently 2.8.0 released in 2020.

While 20030203.000550 is a higher version according to the Maven Version Order Specification, it does not indicate anything about the release date.

Yet the API documentation at https://search.maven.org/classic/#api says "most recent version released", similarly the API response field is called latestVersion. However it actually returns the highest version, e.g. for commons-io that is 20030203.000550.

Example API requests:

Interestingly https://search.maven.org/solrsearch/select?q=g:%22commons-io%22+AND+a:%22commons-io%22&core=gav&rows=25&wt=json does sort by release date and not version name (though this is not clearly documented).

How could we solve this issue? (Not knowing is okay!)

There are probably multiple ways to solve this:

Anything else?

Other projects depending on the API might have to be updated, e.g.: https://github.com/softwaremill/maven-badges

lewismc commented 3 years ago

Hi @Marcono1234 check out https://github.com/sonatype-nexus-community/search-maven-org/issues/149 it is related. You should be able to sort on the following fields score desc,timestamp desc,g asc,a asc,v desc but I don't think you can. The solr documentation provides more information.