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

@nxus/searcher

v2.4.0-3

Published

A search framework for Nxus apps

Downloads

6

Readme

@nxus/searcher

Build Status

The Searcher module enables easy searching of Nxus models using different adapters for Solr, ElasticSearch and others.

Installation

> npm install @nxus/searcher --save

Usage

Configuration

The Searcher module depends on @nxus/storage. The first step is adding and configuring the search adapter you'd like to use. For example, if we want to enable ElasticSearch, we first install the waterline-elasticsearch adapter, then setup the configuration options in the Storage config.

npm install waterline-elasticsearch --save

then add to package.json

"storage": { "adapters": { ... "searcher": "waterline-elasticsearch" }, "connections": { ... "searcher: { "adapter": "searcher", "host": ":9200", "log": "warning", "index": "searcher" } } }

Register model

Now that the correct Storage adapters are configured, you'll need to tell Searcher which models you want to enable search using the searchable method. Searchable accepts an identity for a model which has already been registered.

app.get('searcher').searchable('user')

By default, Searcher will look for a field named title or name to use as the search field. You can specify different, or multiple fields to search by specifying a second options parameter, with the fields key:

app.get('searcher').searchable('user', {fields: 'firstName'}) app.get('searcher').searchable('user', {fields: ['firstName', 'lastName']})

Routes

Based on the model identify, Searcher will create the following routes

/users/search

which accepts a search parameter q. So to search for the term 'pizza':

/users/search?q=mike

The search wil return a list of results using the views below.

Views

You can provide search specific views to be used for search results:

  1. search-user-list: the list view for returned search results.
  2. search-user-detail: the detail view for an individual search result.

Alternatively, if no search templates are found, searcher will automatically use the @nxus/base-ui views for any model that is searchable (if they exist).

  1. view-user-list: the list view used to display search results.
  2. view-user-detail: the detail view linked to from the list view.

Finally, searcher will use default list/detail views if no other templates are found.

API

Searcher

The Search class enables automated searching of models using different adapters.

searchable

Register a model to be searchable.

Parameters

  • model string the model identity
  • opts Object=(default {}) An optional hash of options.