How to use the solr-client.createClient function in solr-client

To help you get started, we’ve selected a few solr-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mark-watson / javascript_intelligent_systems / src / solr_query.js View on Github external
// @flow

var solr = require('solr-client');

// assume server is running on localhost:
var i, j, client = solr.createClient();

var query2 = client.createQuery()
  .q({name: 'radeon'})
  .start(0)
  .rows(10);

client.search(query2, function (error, result) {
  if (error) {
    console.log(error);
  } else {
    var response = result["response"];
    var docs = response["docs"];
    for (i = 0; i < docs.length; i++) {
      console.log("Name: " + docs[i].name);
      if (docs[i].cat) {
        for (j = 0; j < docs[i].cat.length; j++) {
github mark-watson / javascript_intelligent_systems / src / solr_add_data.js View on Github external
// @flow
var solr = require('solr-client');

// assume server is running on localhost:
var client = solr.createClient();
client.autoCommit = true;

// Add a new document
client.add({ id: 12345, name: 'Radeon Imperial Star Fighter', cat: [], features: [] },function(error, result){
  if(error){
    console.log(error);
  }else{
    console.log('Solr response:' + result);
  }
});
github KRMAssociatesInc / eHMP / ehmp / product / production / vx-sync / utils / poller-utils.js View on Github external
function buildEnvironment(logger, config) {
    var metricsLog = new Metrics(config);
    var jds = new JdsClient(logger, metricsLog, config);
    var terminology = new TerminologyUtil(logger, metricsLog, config);
    var environment = {
        vistaClient: new VistaClient(logUtil.getAsChild('vista-client', logger), metricsLog, config, null),
        jobStatusUpdater: {},
        publisherRouter: {},
        errorPublisher: {},
        mvi: new MviClient(logUtil.getAsChild('mvi', logger), metricsLog, config, jds),
        jds: jds,
        metrics: metricsLog,
        terminologyUtils: terminology,
        solr: SolrClient.createClient(config.solrClient)
    };

    environment.jobStatusUpdater = new JobStatusUpdater(logUtil.getAsChild('JobStatusUpdater', logger), config, environment.jds);
    environment.publisherRouter = new PublisherRouter(logUtil.getAsChild('router', logger), config, metricsLog, environment.jobStatusUpdater);
    environment.errorPublisher = new ErrorPublisher(logger, config);
    environment.errorPublisher.connect();

    // Hack around solr-client a little so it runs correctly against our instance
    environment.solr.autoCommit = true;
    environment.solr.UPDATE_JSON_HANDLER = 'update';

    return environment;
}
github geneontology / noctua / epione.js View on Github external
});
	
///
/// Startup.
///

// Set the actual target.
var u = url.parse(golr_location);
var client_opts = {
    solrVersion: '3.6',
    host: u.hostname,
    port: u.port,
    path: ustr(u.path).rtrim('/').value()
};
//ll(client_opts);
var solr_client = solr.createClient(client_opts);
//var solr_client = solr.createClient(u.hostname, u.port, '', u.path);

// Not in our version?
// // Ping solr server. Only continue if.
// solr_client.ping(function(err, obj){
//    if(err){
//        _die('Could not make contact with GOlr server!');
//    }else{
//    	ll(obj);
//    }
// });

///
/// Start by flushing the current contents.
///
github lando / lando / examples.old / solr / app.js View on Github external
'use strict';

// Load modules
const http = require('http');
const express = require('express');
const solr = require('solr-client');
const app = express();

// Create solr client
// This uses the internal_connection info from `lando info`.
const client = new solr.createClient({
  host: 'index',
  port: '8983',
  core: 'freedom',
  solrVersion: '5.1',
});

// Create our servers
http.createServer(app).listen(80);

// Basic HTTP response
app.get('/', (req, res) => {
  // Set the header
  res.header('Content-type', 'text/html');
  // Ping the solr intance
  client.ping((err, result) => {
    if (err) {
github watson-developer-cloud / node-sdk / retrieve-and-rank / v1.js View on Github external
RetrieveAndRankV1.prototype.createSolrClient = function(params) {
  params = params || {};

  const missingParams = helper.getMissingParams(params, ['cluster_id', 'collection_name']);
  if (missingParams) {
    throw missingParams;
  }

  const serviceUrl = url.parse(this._options.url);
  const apiPath = serviceUrl.path === '/' ? '' : serviceUrl.path || '';

  const solrClient = solr.createClient({
    host: serviceUrl.hostname,
    path: apiPath + '/v1/solr_clusters/' + params.cluster_id + '/solr',
    port: serviceUrl.port || '443',
    secure: true,
    core: params.collection_name
  });

  if (this._options.username && this._options.password) {
    solrClient.basicAuth(this._options.username, this._options.password);
  }
  return solrClient;
};
github watson-developer-cloud / node-sdk / services / search / v1.js View on Github external
Search.prototype.createSolrClient = function(params) {
  if (!params || !params.clusterId) {
    throw new Error('Missing required parameter: clusterId');
  } else if (!params.collectionName) {
    throw new Error('Missing required parameter: collectionName');
  }
  var serviceUrl = url.parse(this._options.url);
  var apiPath = serviceUrl.path === '/' ? '' : serviceUrl.path || '';

  var solrClient = solr.createClient({
    host: serviceUrl.hostname,
    path: apiPath + solrClusterPath(params.clusterId) + '/solr',
    port: serviceUrl.port || '443',
    secure: true,
    core: params.collectionName
  });
  solrClient.basicAuth(params.username, params.password);
  return solrClient;
};
github julianlam / nodebb-plugin-solr / library.js View on Github external
Solr.connect = function () {
	if (Solr.client) {
		delete Solr.client;
	}

	Solr.config = {
		...Solr.config,
		secure: Solr.config.secure && Solr.config.secure === 'on',
	};

	Solr.client = engine.createClient(Solr.config);

	if (Solr.config.username && Solr.config.password) {
		Solr.client.basicAuth(Solr.config.username, Solr.config.password);
	}
};

solr-client

A Solr client library for indexing, adding, deleting, committing, optimizing and searching documents within an Apache Solr installation (version>=3.2)

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Popular solr-client functions