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

@zir-ai/searchbox-corejs

v1.0.9

Published

<p align="center"> <a href="https://docs.zir-ai.com/" rel="noopener" target="_blank"><img width="150" src="https://zir-ai.com/logo.svg" alt="Zir-AI logo"></a> </p>

Downloads

35

Readme

This documentation demonstrates how to integrate the ZIR Semantic Search widget into a Javascript application.

npm npm downloads license

For full :page_facing_up: documentation, visit the online documentation.

The search widget connects to a corpus or corpora through API keys. It presents the user with a polished, customizable text box for entering queries, and handles results and errors using callback methods. It also exposes a search(query) method that enables programmatic interaction with the search.

:bulb: Getting Started

Begin by installing the CoreJS package for semantic search:

npm install @zir-ai/searchbox-corejs

The snippet below shows how to initialize the search box and embed it into
a page. This snippet also demonstrates ZIR Semantic Search's ability to
concurrently query multiple corpora and blend the results.

<script>
  let widget = zirSearch.createSearch(
    "zqt_cKg6-joMkEsOa1EbNS-MQefDdC3I7Ct_g3tr2Q", // api key
    1890073338,                                   // customer id
    [148, 157, 160],                              // array of corpus id's
    success,                                      // success function
    error,                                        // error function
    "./download.png",                             // custom icon
    20,                                           // number of results
    "Enter what you want to ask about",           // search placeholder
    false                                         // default focus
  );
  document.getElementById("anchor").appendChild(widget);

  function success(results) {
    // Process the results and display them on the page.
    console.log(results);
  }

  function error(err) {
    // Something went wrong. Show the user an appropriate error message.
    console.log(err);
  }
</script>

API

The zirSearch.createSearch method creates the search box widget, and returns
a component that can be inserted into the DOM of the host page.

A brief description of each method parameter is below:

Mandatory Parameters

  1. apiKey: the API key linked to one or more corpora.
  2. customerID: your account ID.
  3. corpusID: an array of IDs of the corpora to be queried. This can range
    from a single corpus to an account-specific limit, which is generally five.
  4. successFn: a callback function that is invoked when the search results are
    returned. Use this function to render individual results on the page.

Optional Parameters

  1. errorFn: a callback function that is invoked when an error is encountered. This
    function should be used to render a readable error message for the user.
  2. customIcon: the ZIR logo is shown in the search box by default. This can be
    altered by passing in the path to a replacement image.
  3. numResults: the desired number of search results. ten results are returned by
    default. To alter this, pass in any positive integer value up to the
    maximum number allowed by your account.
  4. placeholder: The placeholder text to be displayed in the search box.
  5. focus: If set to true, the search box will receive focus when the page loads.

Pagination

Pagination can be setup using the zirSearch.createPagination(widget)
function. Once createPagination has been called, append the pagination widget
wherever desired in the DOM.

const pagination = zirSearch.createPagination(widget);
document.getElementById("pagination").appendChild(pagination);