npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@relevanceai/instant-relevance

v1.1.0

Published

Install with npm using: ``` npm i @relevanceai/instant-relevance ```

Downloads

7

Readme

Getting started

Install with npm using:

npm i @relevanceai/instant-relevance

Javascript support, using instantsearch.js

import instantsearch from "instantsearch.js";
import {instantRelevanceSearch} from "@relevanceai/instant-relevance";

const searchClient = instantRelevanceSearch({
  project:'dummy-collections',
  api_key:'UzdYRktIY0JxNmlvb1NpOFNsenU6VGdTU0s4UjhUR0NsaDdnQTVwUkpKZw'
});
const search = instantsearch({
  searchClient,
  indexName: "1000-movies"
});
search.start();

React support, react-instantsearch

React movies codesandbox demo

import React from "react";
import ReactDOM from "react-dom";
import { searchbox } from "react-instantsearch-dom";
import {instantRelevanceSearch} from "@relevanceai/instant-relevance";

const searchClient = instantRelevanceSearch({
  project:'dummy-collections',
  api_key:'UzdYRktIY0JxNmlvb1NpOFNsenU6VGdTU0s4UjhUR0NsaDdnQTVwUkpKZw'
});


const App = () => (
  <InstantSearch indexName="1000-movies" searchClient={searchClient}>
    <SearchBox />
    <Hits />
  </InstantSearch>
);

Vue support with vue-instantsearch

Vue ecommerce codesandbox demo

<template>
  <ais-instant-search :search-client="searchClient" index-name="1000-movies">
    <ais-search-box />
    <ais-hits>
      <div slot="item" slot-scope="{ item }">
        <h2>{{ item.name }}</h2>
      </div>
    </ais-hits>
  </ais-instant-search>
</template>

<script>

import { instantRelevanceSearch } from '@relevanceai/instant-relevance';

export default {
  data() {
    const searchClient = instantRelevanceSearch({
      project:'dummy-collections',
      api_key:'UzdYRktIY0JxNmlvb1NpOFNsenU6VGdTU0s4UjhUR0NsaDdnQTVwUkpKZw'
    });
    return {
      searchClient,
    };
  },
};
</script>

Options

const searchClient = instantRelevanceSearch({
  project:'RELEVANCE_PROJECT_NAME',
  api_key:'RELEVANCE_API_KEY',
  options: {
    override: {}, // Sometimes parameters for the RelevanceAI api call need to be replaced. For example: override:{explainRelevance:0.2} will hide less relevant results. All options can be seen here: https://docs.relevance.ai/reference/simplesearchpost
    vector_fields?:['vectorfield_vector_'], // This is easiest way to perform a vector search in addition to traditional search. specify the vector field names here. to customise vector search further, use the 'beforeSearch' option.
    indexToSortMapping:{'indexname1':{'fieldtosort':'asc'},'indexname2':{'fieldtosort':'desc'}}, // This is one of two ways to control sorting. When a sort option is selected by a user, instantsearch will feed in a different indexname. Here you can map each indexname to a sort setting. Alternatively, specify the indexname in the instantsearch sort component in format: indexname/field/asc or indexname/field/desc. An example can be seen in the vue demo under demos/vue-ecommerce/src/App.vue
    indexName:'INITIAL_INDEX_NAME', // instantsearch sometimes changes the index name passed in. Use this to override instantsearches index name.
    beforeSearch:(payload) => {
      payload.minimumRelevance = 0.1;
      return payload;
    }, // This callback gives complete control over the payload body sent to the RelevanceAI api. The first argument is the initial payload body. It must return a valid SimpleSearchPost body as seen here: https://docs.relevance.ai/reference/simplesearchpost
  }
})

Limitations

Node.js / Nuxt.js

Our output uses es2015 module syntax. Node/Nuxt require CommonJS syntax, so our package will need to be transpiled to work.