Yarn package search is available right now at https://yarnpkg.com/search.
This post describes the gift, talks about npm and yarn, details the inner workings and proposes future enhancements.
Happy reading. If you have any questions, ask right here by replying.
This is an instant-search experience enhanced with metadata like the number of downloads, license type, version, owner and last activity.
At Algolia we are relying on it to manage our dependencies, and we are moving every project using npm to yarn.
Publishing packages has never been so easy. As of January 2017 450K+ packages are available in the npm registry.
Developers looking for packages are often finding themselves frustrated by the sheer number of options available. To help them (and us) find and decide which package to use, we wanted to provide an alternative to the npm search.
We wanted this search to be: fast, relevant and enriched with meaningful metadata inside the search results.
We got something running in just one week, built with Algolia's instantsearch.js for the front-end and algolia/npm-search for the npm registry to Algolia replication.
On December 22nd, we submitted a pull request to yarn/website. After one week of review with the yarn team, the pull request was merged and the package search was made public at https://yarnpkg.com/search.
For every NPM package, we create a record in the Algolia index with the following schema:
"description": "Babel compiler core.",
"keywords": ["6to5", "babel", "classes", "const", "es6", "harmony", "let", "modules", "transpile", "transpiler", "var"],
We're restricting the search to use a subset of the attributes only:
Algolia provides default prefix search capabilities (matching words with only the beginning). This is disabled for the
Algolia provides default typo-tolerance. Typo-tolerance is disabled for the
optionalFacetFilters feature of Algolia, we're boosting exact matches on the name of a package to always be on top of the results.
Number of downloads
For each package, we use the number of downloads in the last 30 days to set the
customRanking, which is used to sort the results.
To see this in action, try searching for
babel. This will match both
babel-messages. From a textual relevance point of view, those 2 packages are exactly matching in the same way (the world "babel"). In such case, Algolia will rely on the
customRanking setting and therefore put the package with the highest number of downloads in the past 30 days first.
Some packages will be considered as popular if they are downloaded very frequently. We currently consider packages with greater than
0.005% of the total number of downloads on the whole registry to be popular. A
popular flag is used to boost popular records over non-popular ones.
If you want to learn more about how Algolia's ranking algorithm works, you can read this blog post.
This gift would not have been possible without you, the community. We would also like to thank:
As part of making the search experience with
yarn even better, we plan to:
- Provide a package result page with even more metadata to help you dig into results and details.
- Provide a
yarn search command line tool.
Previous community gifts
In 2014 we offered Awesome Autocomplete for GitHub, a browser extension to add instant search capabilities to GitHub search box.
In 2015 we released DocSearch, the easiest way to add search to your documentation. It's actually used on Yarn's documentation and 250+ other websites.