restmavenmaven-centralsolr-search

How do I get a list of released artifacts sorted by version from Maven Central Search API?


I would like to retrieve a list of released artifacts from the official Maven Central Repository REST API sorted by version. But I don't know how to do that. I have tried with the following example REST URLs:

  1. https://search.maven.org/solrsearch/select?wt=json&q=g:com.fasterxml.jackson.core+AND+a:jackson-core This one is fine because it gives me the current version (2.19.0) but it only returns ONE entry, not a list of released versions in descending order.
  2. https://search.maven.org/solrsearch/select?wt=json&q=g:com.fasterxml.jackson.core+AND+a:jackson-core&sort=vdesc&core=gav This one returns a list of released artifact versions which is what I would like to have but the list is sorted by timestamp and not by version. So as a result the first entry is version 2.18.4 which is the latest version released but it isn't the newest release which is 2.19.0 actually. I hope you understand what I mean.

Unfortunately the parameters of the REST API endpoint are poorly documented. In the second URL I added the parameter 'core=gav' which means the result will be a list but sorted by timestamp as far as I understood ('gav' could be interpreted as groupId, artifactId and version though). Unfortunately there's no information about other characters to use with this parameter.

So does anybody know how to use this API properly to get the desired result? Of course I could use the second approach and then sort the resulting list by myself. But that's not the idea of using a search engine like Apache Solr properly, right?


Solution

  • I contacted Sonatype support and the solution is to use the right URL where the issue is fixed and sorting by version works. For the example used in my question the correct query URL would be:

    https://central.sonatype.com/solrsearch/select?wt=json&q=g:com.fasterxml.jackson.core+AND+a:jackson-core&sort=v+desc