Skip to content

Search API returns irrelevant results #3187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Pzixel opened this issue Jan 18, 2021 · 1 comment
Closed

Search API returns irrelevant results #3187

Pzixel opened this issue Jan 18, 2021 · 1 comment
Labels
A-search C-bug 🐞 Category: unintended, undesired behavior duplicate

Comments

@Pzixel
Copy link

Pzixel commented Jan 18, 2021

Describe the bug
When querying https://crates.io/api/v1/crates results are invalid sometimes

To Reproduce
Steps to reproduce the behavior:

A:

  1. Go to https://crates.io/api/v1/crates?page=1&per_page=20&q=rust_dec&sort=
  2. Observe that results page doesn't have a single rust_dec word, but it produces some irrelevant crates like aocleaderboard, atomic-traits and others

B:

  1. Go to https://crates.io/api/v1/crates?page=1&per_page=20&q=rust_dec
  2. Observe that results page contains rust_dec word, but it also produces some irrelevant crates like z3d, google_maps and others

Expected behavior
It should show the same result as https://crates.io/api/v1/crates?page=1&per_page=20&q=rust_deci&sort= query (note i in the end of the query):

{
   "crates":[
      {
         "id":"rust_decimal",
         "name":"rust_decimal",
         "updated_at":"2020-12-28T16:53:45.360679+00:00",
         "versions":null,
         "keywords":null,
         "categories":null,
         "badges":[
            
         ],
         "created_at":"2016-11-16T16:31:13.547828+00:00",
         "downloads":814045,
         "recent_downloads":210946,
         "max_version":"1.9.0",
         "newest_version":"1.9.0",
         "max_stable_version":"1.9.0",
         "description":"A Decimal Implementation written in pure Rust suitable for financial calculations.",
         "homepage":null,
         "documentation":"https://docs.rs/rust_decimal/",
         "repository":"https://github.com/paupino/rust-decimal",
         "links":{
            "version_downloads":"/api/v1/crates/rust_decimal/downloads",
            "versions":"/api/v1/crates/rust_decimal/versions",
            "owners":"/api/v1/crates/rust_decimal/owners",
            "owner_team":"/api/v1/crates/rust_decimal/owner_team",
            "owner_user":"/api/v1/crates/rust_decimal/owner_user",
            "reverse_dependencies":"/api/v1/crates/rust_decimal/reverse_dependencies"
         },
         "exact_match":false
      },
      {
         "id":"rust_decimal_macro_impls",
         "name":"rust_decimal_macro_impls",
         "updated_at":"2020-07-11T21:49:51.446673+00:00",
         "versions":null,
         "keywords":null,
         "categories":null,
         "badges":[
            
         ],
         "created_at":"2019-02-03T03:22:12.536585+00:00",
         "downloads":32018,
         "recent_downloads":1174,
         "max_version":"1.7.0",
         "newest_version":"1.7.0",
         "max_stable_version":"1.7.0",
         "description":"Shorthand macros to assist creating Decimal types. Do not depend on this directly; use rust_decimal_macros",
         "homepage":null,
         "documentation":"https://docs.rs/rust_decimal/",
         "repository":"https://github.com/paupino/rust-decimal",
         "links":{
            "version_downloads":"/api/v1/crates/rust_decimal_macro_impls/downloads",
            "versions":"/api/v1/crates/rust_decimal_macro_impls/versions",
            "owners":"/api/v1/crates/rust_decimal_macro_impls/owners",
            "owner_team":"/api/v1/crates/rust_decimal_macro_impls/owner_team",
            "owner_user":"/api/v1/crates/rust_decimal_macro_impls/owner_user",
            "reverse_dependencies":"/api/v1/crates/rust_decimal_macro_impls/reverse_dependencies"
         },
         "exact_match":false
      },
      {
         "id":"rust_decimal_macros",
         "name":"rust_decimal_macros",
         "updated_at":"2020-12-28T16:54:49.057667+00:00",
         "versions":null,
         "keywords":null,
         "categories":null,
         "badges":[
            
         ],
         "created_at":"2017-11-11T19:29:52.110872+00:00",
         "downloads":60126,
         "recent_downloads":21243,
         "max_version":"1.9.0",
         "newest_version":"1.9.0",
         "max_stable_version":"1.9.0",
         "description":"Shorthand macros to assist creating Decimal types.",
         "homepage":null,
         "documentation":"https://docs.rs/rust_decimal/",
         "repository":"https://github.com/paupino/rust-decimal",
         "links":{
            "version_downloads":"/api/v1/crates/rust_decimal_macros/downloads",
            "versions":"/api/v1/crates/rust_decimal_macros/versions",
            "owners":"/api/v1/crates/rust_decimal_macros/owners",
            "owner_team":"/api/v1/crates/rust_decimal_macros/owner_team",
            "owner_user":"/api/v1/crates/rust_decimal_macros/owner_user",
            "reverse_dependencies":"/api/v1/crates/rust_decimal_macros/reverse_dependencies"
         },
         "exact_match":false
      }
   ],
   "meta":{
      "total":3,
      "next_page":null,
      "prev_page":null
   }
}

Screenshots

image

@Pzixel Pzixel added the C-bug 🐞 Category: unintended, undesired behavior label Jan 18, 2021
@Pzixel Pzixel changed the title Search using API returns unappripriate results Search API returns irrelevant results Jan 18, 2021
bors bot added a commit to intellij-rust/intellij-rust that referenced this issue Jan 25, 2021
6691: Update CratesIoApi.kt r=vlad20012 a=Pzixel

Fixes issues with irrelevant search results due to empty $sort: https://github.com/rust-lang/crates.io/blob/master/src/controllers/krate/search.rs#L65

Fore more details see rust-lang/crates.io#3187

Ideally plugin should narrow the search results even further using `startsWith` on `crates.io` response since not all of the results are really relevant.

Co-authored-by: Psilon <[email protected]>
@Turbo87
Copy link
Member

Turbo87 commented Jan 30, 2021

thanks for reporting this @Pzixel. I share your view that the search algorithm needs to be improved, though at the moment it is not clear for us yet exactly how we can improve it. We have a similar issue already reported at #2739, so I'll go ahead and close this one as a duplicate. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-search C-bug 🐞 Category: unintended, undesired behavior duplicate
Projects
None yet
Development

No branches or pull requests

2 participants