0.2.1 • Published 10 years ago

netaphor-search-client v0.2.1

Weekly downloads
2
License
-
Repository
github
Last release
10 years ago

Netaphor search client

A Node client for the Netaphor Search API.

##Contents

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

.search()

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

10 years ago

0.2.0

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

11 years ago