Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Simple Solr Node Client Project
npm install solr-node
// Require module
var SolrNode = require('solr-node');
// Create client
var client = new SolrNode({
host: '127.0.0.1',
port: '8983',
core: 'test',
protocol: 'http'
});
// Set logger level (can be set to DEBUG, INFO, WARN, ERROR, FATAL or OFF)
require('log4js').getLogger('solr-node').level = 'DEBUG';
Search can be executed with a simple text query or an object query.
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 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)
;
// Create query
var strQuery = client.query().q('text:test');
var objQuery = client.query().q({text:'test', title:'test'});
var myStrQuery = 'q=text:test&wt=json';
// Search documents using strQuery
solrClient.search(strQuery, function (err, result) {
if (err) {
console.log(err);
return;
}
console.log('Response:', result.response);
});
// Search documents using objQuery
solrClient.search(objQuery, function (err, result) {
if (err) {
console.log(err);
return;
}
console.log('Response:', result.response);
});
// Search documents using myStrQuery
solrClient.search(myStrQuery, function (err, result) {
if (err) {
console.log(err);
return;
}
console.log('Response:', result.response);
});
// JSON Data
var data = {
text: 'test',
title: 'test'
};
// Update document to Solr server
client.update(data, function(err, result) {
if (err) {
console.log(err);
return;
}
console.log('Response:', result.responseHeader);
});
// Delete Query
var strQuery = 'id:testid'
var objQuery = {id:'testid'}
// Delete document using strQuery
client.delete(strQuery, function(err, result) {
if (err) {
console.log(err);
return;
}
console.log('Response:', result.responseHeader);
});
// Delete document using objQuery
client.delete(objQuery, function(err, result) {
if (err) {
console.log(err);
return;
}
console.log('Response:', result.responseHeader);
});
Skip the callback to get a promise back. ie:
var result = solrClient.search(query)
.then(function(result) {
console.log('Response:', result.response);
})
.catch(function(err) {
console.error(err);
});
You can also use async
/await
:
try {
const result = await solrClient.search(query);
console.log('Response:', result.response);
} catch(e) {
console.error(err);
}
gulp
FAQs
Simple Solr Node Client Project
The npm package solr-node receives a total of 940 weekly downloads. As such, solr-node popularity was classified as not popular.
We found that solr-node demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.