@pimred/solrcloud

Connect to a SolrCloud in node.js.

Usage no npm install needed!

<script type="module">
  import pimredSolrcloud from 'https://cdn.skypack.dev/@pimred/solrcloud';
</script>

README

SolrCloud client

Connect to a SolrCloud in node.js.

This library uses Zookeeper to determine the connection to the SolrCloud and returns an instance of Axios that can be used to send requests to the Solr node.

A list of Solr nodes is being retrieved from Zookeeper. The Solr node is being selected randomly.

A basic failover implementation is done by selecting a new node if a request fails.

Installation

npm install --save @pimred/solr-cloud

Usage

const solrCloud = require('@pimred/solr-cloud')

const options = {
  zkConnectionString: 'Connection to Zookeeper',
  collection: 'Name of the Solr collection'
}

solrCloud.createClient(options).then(client => {
  client.get('select', {
    params: {
      q: '*:*'
    }
  }).then(response => console.log(response.data))
})

API documentation

createClient(options)

This creates the Solr client which is in fact an instance of axios.

Options

Name Required Description
zkConnectionString x Connection string to Zookeeper|
collection x Name of the collection in Solr
maxRetries Maximum number of retries when handling a failed request to Solr

zkConnectionString

https://github.com/alexguan/node-zookeeper-client#documentation

connectionString String - Comma separated host:port pairs, each represents a ZooKeeper server. You can optionally append a chroot path, then the client would be rooted at the given path. e.g.

'localhost:3000,locahost:3001,localhost:3002'
'localhost:2181,localhost:2182/test'

escapeSpecialChars(input)

Escape special characters that are part of the query syntax of Lucene

Options

Name Required Description
input x string to escape