Latest Threat ResearchGlassWorm Loader Hits Open VSX via Developer Account Compromise.Details
Socket
Book a DemoInstallSign in
Socket

netaphor-search-client

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

netaphor-search-client

A module for easy communication with the Netaphor search API

unpublished
latest
Source
npmnpm
Version
0.2.1
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Netaphor search client

A Node client for the Netaphor Search API.

##Contents

  • Instantiation
  • search
  • update
  • optimize
  • deleteItem
  • commit
  • examples

Instantiation

To include in node:

var neta4 = require('netaphor-search-client');

Creating a new connector:

var searchConnector = new neta4.Connector(config);

Parameters:

config an object with the following properties username (String), password (String), clientId (String)

Methods

Query a hosted Solr search index

Syntax:

searchConnector.search(searchQuery, callback)

Parameters:

searchQuery the full search query as a String or an object. If using a string be sure to include a "?" at the beginning.

callback a callback function called when the search server responds which accepts two parameters; error and response. response being the body of the http response from the search server.

.update()

Add or modify data in the Solr search index

Syntax:

searchConnector.update(postData, callback)

Parameters:

postData a String in either JSON or XML format used to update or populate the search index.

callbacka function called when the search server responds which accepts two parameters; error and response. response being the body of the http response from the search server.

.optimize()

Used to optimize the Solr search index

searchConnector.optimize(callback)

Parameters:

callbacka function called when the search server responds which accepts two parameters; error and response. response being the body of the http response from the search server.

.deleteItem()

Delete an item from the Solr search index using its id

Syntax:

searchConnector.update(itemId, callback)

Parameters:

itemId a String or Integer which is the items id

callbacka function called when the search server responds which accepts two parameters; error and response. response being the body of the http response from the search server.

.commit()

Commit changes to the Solr search index

Syntax:

searchConnector.commit(callback)

Parameters:

callbacka function called when the search server responds which accepts two parameters; error and response. response being the body of the http response from the search server.

Quick examples

var neta4 = require('netaphor-search-client');

// Required parameters
var config = {
		clientId:			'yourServerName',
		username:			'should.be.an@email.com',
		password:			'yourPassword'
	};

// Create a new search connector 
var neta4Search = new neta4.Connector(config);

// Load up some data
var data = fs.readFileSync('someData.xml');

// Send the data to the search index
neta4Search.update(data, function (error, response) {
	if (error !== null) {
		console.log('Error with request', error);
	} else {
		// Data successfully submitted
	}	
});	

// Commit your search changes
neta4Search.commit(function (error, response) {
	if (error !== null) {
		console.log('Error with request', error);
	} else {
		// Changes commited to the index and ready to query
	}
});

// Optimize the search index
neta4Search.optimize(function (error, response) {
	if (error !== null) {
		console.log('Error with request', error);
	} else {
		// Index optimized
	}
});

// Search your index
neta4Search.search('?q=*:*&wt=json&qt=standard&rows=10&facet=true', function (error, response) {
	if (error !== null) {
		console.log('Error with request', error);
	} else {
		// Do stuff with the results
	}
});

// Delete an item from the search index
neta4Search.deleteItem(itemId, function (error, response) {
	if (error !== null) {
		console.log('Error with request', error);
	} else {
		// Item marked for deletion, commit your changes to remove the item
	}
});

Keywords

netaphor

FAQs

Package last updated on 09 Feb 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts