Node.js client for OSS
A Node.js client for Open Search Server.
See also parent module oss-odm.
Install
npm install node-oss-client
Example
var oss = client = oss; client;
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;
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;
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;
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;
Indexes
client.indexes.create(index, [options], callback)
Create a new index, you can specify a template with options.template
.
clientindexes;
client.indexes.exists(index, callback)
Test if an index exists.
clientindexes;
client.indexes.destroy(index, callback)
Destroy an existing index.
clientindexes;
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.
clientfields;
client.fields.list(index, callback)
List all index fields.
clientfields;
client.fields.destroy(index, field, callback)
Destroy an existing field on an existing index.
clientfields;
client.fields.setUniqueDefault(index, options, callback)
Specify a default and unique index.
clientfields;
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.
clienttemplates;
client.templates.list(index, callback)
List all search templates associated to the specified index.
clienttemplates;
client.templates.get(index, name, callback)
Get a search template.
clienttemplates;
client.templates.destroy(index, name, callback)
Destroy a search template.
clienttemplates;
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.
clientdocuments;
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
).
clientdocuments;
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).
clientreplication;
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).
clientreplication;
License
MIT