nolr
This project is a fork of the Simple Solr Node Client Project.
Install
npm install nolr
Create Client
// Require moduleconst nolr = ; // Create clientconst client = host: '127.0.0.1' port: '8983' core: 'test' protocol: 'http'; // Set Debug Levelconst client = host: '127.0.0.1' port: '8983' core: 'test' protocol: 'http' debugLevel: 'ERROR' // log4js debug level paramter;
Search
Search can be executed with a simple text query or an object query.
Text
Text queries are similar to what one would find on the SOLR Core UI, EX:
From the URL: http://localhost:8080/solr/products/select?q=*%3A*&wt=json
The Query would be:
*:*&wt=json
NOTE: url decoded ':' from %3A
.
Object
Object based queries can be simple or complex using chaining. Each method of the Query object returns an instance of itself.
Examples:
Simple:
client.query().q({text:'test', title:'test'});
Complex and chained:
client.query()
.q({text:'test', title:'test'})
.addParams({
wt: 'json',
indent: true
})
.start(1)
.rows(1)
;
Query Examples
// Create querylet strQuery = client;let objQuery = client;let myStrQuery = 'q=text:test&wt=json'; // Search documents using strQueryclient; // Search documents using objQueryclient; // Search documents using myStrQueryclient;
Update
// JSON Datalet data = text: 'test' title: 'test'; // Update one document to Solr serverclient; // JSON Array Data, takes both array or JSON Lineslet data = text: 'test1' title: 'test1' text: 'test2' title: 'test2' text: 'test3' title: 'test3'; // Update one document to Solr serverclient;
Delete
// Delete Querylet strQuery = 'id:testid'let objQuery = id:'testid' // Delete document using strQueryclient; // Delete document using objQueryclient;
Promise support
Skip the callback to get a promise back. ie:
const result = solrClient ;
Test & Coverage & Docs
gulp