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

node-oss-client

v2.1.5

Published

Node.js client for Open Search Server.

Downloads

33

Readme

Node.js client for OSS Build Status

A Node.js client for Open Search Server.

See also parent module oss-odm.

Install

npm install node-oss-client

Example

var oss = require('node-oss-client'),
  client = oss.createClient();

client.search('my_index', {
  query: 'my query'
}, function (err, res) {
  // ...
});

See the examples directory in this repo for more examples.

Usage

Client

oss.createClient(options)

Create a new client. Available options are

  • hostname
  • port
  • protocol
  • login
  • key
var client = oss.createClient({
  hostname: 'my.host.com',
  port: 8080,
  protocol: 'http'
});

Search

client.search(index, options, callback)

Search in a custom index, you can specify search type with options.type (field or pattern). Others options are avalaible in OSS Documentation.

client.search('my_index', {
  query: 'my_query'
}, function (err, res) { });

More like this

client.moreLikeThis(index, options, callback)

Request a more like this query on a custom index. Available options can be found in OSS Documentation.

client.moreLikeThis('my_index', {
  likeText: 'Text to search for similarity'
}, function (err, res) { });

Autocompletion

client.autocompletion(index, item, options, callback)

Request autocompletion on an auto-completion item of a custom index. Available options can be found in OSS Documentation.

client.autocompletion('my_index', 'autocomplete_item', {
  prefix: 'Text to complete'
}, function (err, res) { });

Indexes

client.indexes.create(index, [options], callback)

Create a new index, you can specify a template with options.template.

client.indexes.create('my_index', [options], function (err, res) { });

client.indexes.exists(index, callback)

Test if an index exists.

client.indexes.exists('my_index', function (err, res) { });

client.indexes.destroy(index, callback)

Destroy an existing index.

client.indexes.destroy('my_index', function (err, res) { });

Fields

client.fields.createOrUpdate(index, options, callback)

Create or update a new field on an existing index. Options are avalaible in OSS Documentation.

Aliases: client.fields.update, client.fields.create.

client.fields.create('my_index', {
  name: 'my_field'
}, function (err, res) { });

client.fields.list(index, callback)

List all index fields.

client.fields.list('my_index', function (err, res) { });

client.fields.destroy(index, field, callback)

Destroy an existing field on an existing index.

client.fields.destroy('my_index', 'my_field', function (err, res) { });

client.fields.setUniqueDefault(index, options, callback)

Specify a default and unique index.

client.fields.setUniqueDefault('my_index', { unique: 'my_unique_field', default: 'my_default_field' }, function (err, res) { });

Search templates

client.templates.createOrUpdate(index, name, options, callback)

Create or update a search template. Options are avalaible in OSS Documentation.

Aliases: client.templates.update, client.templates.create.

client.templates.create('my_index', 'my_template', { returnedFields: ['my_field'] }, function (err, res) { });

client.templates.list(index, callback)

List all search templates associated to the specified index.

client.templates.list('my_index', function (err, res) { });

client.templates.get(index, name, callback)

Get a search template.

client.templates.get('my_index', 'my_template', function (err, res) { });

client.templates.destroy(index, name, callback)

Destroy a search template.

client.templates.destroy('my_index', 'my_template', function (err, res) { });

Documents

client.documents.createOrUpdate(index, options, callback)

Create or update documents on an existing index. Options are avalaible in OSS Documentation.

Aliases: client.documents.update, client.documents.create.

client.documents.create('my_index', [
  {
    lang: 'FRENCH',
    fields: [
      {name: 'id', value: 1},
      {name: 'content', value: 'Hello world!'}
    ]
  },
  {
    lang: 'FRENCH',
    fields: [
      {name: 'id', value: 2},
      {name: 'content', value: 'Hello world 2!'}
    ]
  }
], function (err, res) { });

client.documents.destroy(index, options, callback)

Destroy existing documents on an existing index. You must specify a field (options.field) and some values (options.values).

client.documents.destroy('my_index', {
  field: 'id',
  values: [1, 2]
}, function (err, res) { });

Replication

client.replication.createIndexReplication(index, searcher, callback)

Creates an index of replication on an OSS server. You must specify an object searcher with 3 keys : hostname, port and an optional protocol (http by default).

client.replication.createIndexReplication('my_index', {
  hostname: 'searcher-oss.com',
  port: 8080,
  protocol: 'http'
}, function (err, res) { });

client.replication.replicate(index, searcher, callback)

Starts a replication of the index passed as argument on an other OSS server passed as argument. You must specify an object searcher with 3 keys : hostname, port and an optional protocol (http by default).

client.replication.replicate('my_index', {
  hostname: 'searcher-oss.com',
  port: 8080,
  protocol: 'http'
}, function (err, res) { });

License

MIT