Skip to content
This repository has been archived by the owner on Aug 14, 2021. It is now read-only.

jaeksoft/node-oss-client

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node.js client for OSS Build Status

A Node.js client for Open Search Server.

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) {
  // ...
});

Usage

Client

oss.createClient(options)

Create a new client, avalaible options are hostname, port and protocol.

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) { });

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.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) { });

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) { });

About

Node.js client for Open Search Server.

Resources

Stars

Watchers

Forks

Packages

No packages published