Socket
Socket
Sign inDemoInstall

node-solr-request

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node-solr-request

Lightweight solr client for CRUD operations


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Created
Weekly downloads
 

Readme

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

Last updated on 21 Sep 2015

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc