🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

node-solr-request

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-solr-request

Lightweight solr client for CRUD operations

0.1.4
latest
71

Supply Chain Security

100

Vulnerability

87

Quality

76

Maintenance

100

License

Unpopular package

Quality

This package is not very popular.

Found 1 instance in 1 package

Network access

Supply chain risk

This module accesses the network.

Found 1 instance in 1 package

Version published
Maintainers
1
Created

node-solr-request

A lightweight node.js Solr client

Usage example

The following sample uses Express

var solrRequest = require('node-solr-request');
var express     = require('express');
var bodyParser  = require('body-parser');
var fs          = require('fs');
var app         = express();

// configure body parser
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());

var port = process.env.PORT || 8080;

var settings = '{
                  "serverAddress":"[SOLR SERVER URL OR IP]",
                  "solrCore":"\/solr\/[SOLR CORE NAME]",
                  "solrPort":"[YOUR SOLR PORT NUMBER]",
                  "solrUpdatePath":"\/update\/json?commitWithin=300",
                  "solrDataPath":"\/select"
                }';

var objRequest = new solrRequest(settings);

var router = express.Router();

router.use(function(req, res, next) {
	// do logging
	next();
});

router.route('/solrQuery')
	.post(function(req, res) {
		objRequest.insertDocument(req.body, res);
	})

	.get(function(req, res) {
		objRequest.getDocuments('*', req.query, res)
	});

router.route('/solrQuery/:queryString')
	.get(function(req, res){
		objRequest.getDocuments(req.params.queryString, req.query, res);
	});

app.use('/solr-api', router);

app.listen(port);
console.log('Listening on port ' + port);

example URLS

URLRESULT
[SERVER NAME]/solr-api/solrQuerywill return all documents based on your solr defaults
[SERVER NAME]/solr-api/solrQuery?filters={"field-name":"filter_value","field-name2":"filter_value"}will return all documents based on your solr defaults and filters specified
[SERVER NAME]/solr-api/solrQuery?params={"rows":5,"start":10}will return 5 documents starting with the 10th document
[SERVER NAME]/solr-api/solrQuery?filters={"field-name":"filter_value","field-name2":"filter_value"}&params={"rows":5}will return maximum 5 documents based on your filters specified
[SERVER NAME]/solr-api/solrQuery/widgetwill search for the string "widgets" and return all found documents based on your solr defaults
[SERVER NAME]/solr-api/solrQuery/widget?filters={"field-name":"filter_value","field-name2":"filter_value"}&params={"rows":5}will search for the string "widgets" and return maximum 5 found documents based on your filters specified

Keywords

FAQs

Package last updated on 21 Sep 2015

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