NuGet / NuGetGallery

NuGet Gallery is a package repository that powers https://www.nuget.org. Use this repo for reporting NuGet.org issues.
https://www.nuget.org/
Apache License 2.0
1.55k stars 641 forks source link

[NuGet.org Bug]: Api query does not return all results, compared to web search #10274

Closed samtrion closed 3 days ago

samtrion commented 3 days ago

Impact

It bothers me. A fix would be nice

Describe the bug

When I search for my Nuget packages via nuget.org, I currently get 40 packages as a result set. If I search via the api, with the same term, I always get one result less.

It is always the same package (https://www.nuget.org/packages/NetEvolve.Extensions.XUnit.V3), which is missing and I have not been able to identify the cause. I have also tried additional parameters such as for a pre-release, without success.

Repro Steps

See enclosed links

Expected Behavior

The same number of Nuget packages is listed for me.

Screenshots

No response

Additional Context and logs

No response

joelverhagen commented 3 days ago

There are two "latest" filters that are applied to the search results: "include prerelease" and "include SemVer 2.0.0". The web UI has a checkbox for include prerelease and SemVer 2.0.0 packages are always included. This is not the case for the API and SemVer 2.0.0 and prerelease versions are excluded by default for backwards compatibility. This second filter (SemVer level) is what is causing the difference.

Consider: https://azuresearch-usnc.nuget.org/query?q=netevolve&prerelease=true&semVerLevel=2.0.0 (40 results) vs. https://azuresearch-usnc.nuget.org/query?q=netevolve (39 results)

See https://learn.microsoft.com/en-us/nuget/api/search-query-service-resource#request-parameters for more information.

Also note that the host name you are using is deprecated. It is not mentioned in the V3 service index at all and is only supported for legacy reasons, with no long term commitment. Make sure to discover search base URLs using the V3 service index: https://api.nuget.org/v3/index.json

You can implement this endpoint discovery yourself or you can use the .NET client SDK: https://learn.microsoft.com/en-us/nuget/reference/nuget-client-sdk#search-packages

samtrion commented 3 days ago

Consider: https://azuresearch-usnc.nuget.org/query?q=netevolve&prerelease=true&semVerLevel=2.0.0 (40 results)

Thank you, @joelverhagen, for the very detailed explanation, you were able to help me directly. I was able to use the highlighted URL directly. Thank you very much.