Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-solr-request

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

node-solr-request

Lightweight solr client for CRUD operations

  • 0.1.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc