Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// @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++) {
// @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);
}
});
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;
}
});
///
/// 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.
///
'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) {
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;
};
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;
};
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);
}
};