sonatype / nexus-public

Sonatype Nexus Repository Open-source codebase mirror
https://www.sonatype.com/products/repository-oss-download
Eclipse Public License 1.0
1.96k stars 578 forks source link

Searching for empty "maven.classifier" doesn't work #512

Open marcinus opened 1 week ago

marcinus commented 1 week ago

Neither of the following requests return any results:

http://nexus-host/service/rest/v1/search/assets?repository=company-snapshots&group=com.company.product&name=some-service&maven.baseVersion=2.0.5-SNAPSHOT&maven.extension=jar&maven.classifier=""

http://nexus-host/service/rest/v1/search/assets?repository=company-snapshots&group=com.company.product&name=some-service&maven.baseVersion=2.0.5-SNAPSHOT&maven.extension=jar&maven.classifier=

http://nexus-host/service/rest/v1/search/assets?repository=company-snapshots&group=com.company.product&name=some-service&maven.baseVersion=2.0.5-SNAPSHOT&maven.extension=jar&maven.classifier

Whereas the following returns results (the only difference is lack of maven.classifier selector)

http://nexus-host/service/rest/v1/search/assets?repository=company-snapshots&group=com.company.product&name=some-service&maven.baseVersion=2.0.5-SNAPSHOTS&maven.extension=jar

    "downloadUrl" : "http://nexus-host/repository/company-snapshots/com/company/product/some-service/2.0.5-SNAPSHOT/some-service-2.0.5-20241111.152915-3-tests.jar",
    "path" : "com/company/product/some-service/2.0.5-SNAPSHOT/some-service-2.0.5-20241111.152915-3-tests.jar",
    "id" : "XXX",
    "repository" : "company-snapshots",
    "format" : "maven2",
    "checksum" : {
      "sha1" : "XXX",
      "sha256" : "XXX",
      "sha512" : "XXX",
      "md5" : "XXX"
    },
    "contentType" : "application/java-archive",
    "lastModified" : "2024-11-11T15:30:47.693+00:00",
    "lastDownloaded" : null,
    "uploader" : "developer",
    "uploaderIp" : "XXX",
    "fileSize" : 1056248,
    "maven2" : {
      "extension" : "jar",
      "groupId" : "com.company.product",
      "classifier" : "tests",
      "artifactId" : "some-service",
      "version" : "2.0.5-20241111.152915-3"
    }
  }, {
    "downloadUrl" : "http://nexus-host/repository/company-snapshots/com/company/product/some-service/2.0.5-SNAPSHOT/some-service-2.0.5-20241111.152211-3.jar",
    "path" : "com/company/product/some-service/2.0.5-SNAPSHOT/some-service-2.0.5-20241111.152211-3.jar",
    "id" : "XXXX",
    "repository" : "company-snapshots",
    "format" : "maven2",
    "checksum" : {
      "sha1" : "XXX",
      "sha256" : "XX",
      "sha512" : "XXX",
      "md5" : "XXX"
    },
    "contentType" : "application/java-archive",
    "lastModified" : "2024-11-11T15:30:46.354+00:00",
    "lastDownloaded" : "2024-11-12T10:49:44.340+00:00",
    "uploader" : "developer",
    "uploaderIp" : "XXX",
    "fileSize" : 125574861,
    "maven2" : {
      "extension" : "jar",
      "groupId" : "com.company.product",
      "artifactId" : "some-service",
      "version" : "2.0.5-20241111.152211-3"
    }
  } ],
  "continuationToken" : null
}

Yes. I can use the working query with jq selector: jq -r '.items | map(select(has("maven2") and (.maven2 | has("classifier") | not))) | sort_by(.lastModified) | reverse | last | .downloadUrl'

Integration with pipelines downloading the latest SNAPSHOT version.

Probably there's an issue with Elasticsearch index on this property?

OSS 3.58.1-02, RHEL8.10 and Orient Embedded DB