Socket
Socket
Sign inDemoInstall

solr-query

Package Overview
Dependencies
66
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    solr-query

An attempt to make solr searches a little more user-friendly


Version published
Weekly downloads
4
increased by100%
Maintainers
1
Install size
6.21 MB
Created
Weekly downloads
 

Readme

Source

solr-query

This project is an attempt at making Solr searches a little easier. I'm sure I'm not the only person that's struggled with trying to build a correct query string for Solr.

Notes

This is an in-progress project. For now, only Solr /search and /update is supported.

Installing

npm install solr-query
const Client = require( 'solr-query' );

const solrC = new Client();

solrC.search( searchQuery, searchOptions );

newRequest.save( obj )
.then( data => {
	console.log( "data:", data );
} ).catch( err => {
	console.log( "err:", err );
} );

Methods

Solr Configuration

When spawning a new Client object, you may pass in options to connect to your instance of Solr. The optional parameters are listed in the config folder.

.search( searchQuery, searchOptions )

searchQuery

This will accept a variety of options. It can be a string, an array, or an object. There are a combination of possibilities with Objects. If your search query is: q=Money AND (USD OR GBP), you can pass an object of:

searchQuery = {
    '$and' : [ 'Money', { '$or' : [ 'USD', 'GBP' ] } ]
}
searchOptions

options.logging( function ); ( You may pass in any function, or console.log to print to console.) This will output the request object that will be sent. It should allow you to see the URL, Method, and qs parameters.

options.commonParams This is where you would pass in any solr-specific query parameters that do not need formatted.

For example: ?qf=contents&limit=100 would be passed as

options.commonParams = {
    'qf'    : 'contents',
    'limit' : 100
};

Please note, if you pass a q parameter into this, it will override the searchQuery that is passed in.

.save( solrObj )

solrObj

This currently accepts a json object that will be entered verbatim into Solr.

solrObj = {
	"title" : "Kinda Cool",
	"uid"   : "b5546172-713a-44f8-9105-761158ca75d9"
}

Running the tests

npm test

Authors

  • Matthew Young - Initial work - mashu-daishi

FAQs

Last updated on 27 Jan 2018

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