Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
ESQ is a helper module for elasticsearch. It aims to provide an easy way of creating elasticsearch queries.
var ESQ = require('esq');
var esq = new ESQ();
var query = null;
query = esq.bool('filtered', 'query', 'bool', 'must', esq.match('foo', 'bar'));
query = esq.bool('filtered', 'query', 'bool', 'must', esq.match('date', '2014-02-01'));
query = esq.bool('filtered', 'query', 'bool', 'should', esq.range('time', '12:00', '13:00'));
query = esq.bool('filtered', 'query', 'bool', 'minimum_should_match', 1);
// query == {
// "filtered": {
// "query": {
// "bool": {
// "must": {
// "match": {
// "date": "2014-02-01"
// }
// },
// "should": {
// "range": {
// "time": {
// "gte": "12:00",
// "lte": "13:00"
// }
// }
// },
// "minimum_should_match": 1
// }
// }
// }
//}
var ESQ = require('esq');
var esq = new ESQ();
esq.query('query', esq.match('foo', 'bar'));
esq.query('query', esq.range('x', '1', '5'));
esq.query('query', esq.wildcard('test', 'what'));
var query = esq.getQuery();
// query == {
// "query": {
// "match": {
// "foo": "bar"
// },
// "range": {
// "x": {
// "gte": "1",
// "lte": "5"
// }
// },
// "wildcard": {
// "test": {
// "value": "what"
// }
// }
// }
//}
npm install esq
Coming soon!
You can pass the function as many strings as you want and you'll receive a nested object with the arguments as keys. The final value (query component) will be assigned to the final object.
Example
esq.query('filtered', 'query', esq.match('foo', 'bar'));
Generates
{
filtered: {
query: {
match: {
foo: 'bar'
}
}
}
}
Same as above, however the second to last parameter must be one of the following operators: must, must_not, should or minimum_should_match. This will ensure that the final value is assigned correctly or pushed into an array.
Example
esq.bool('filtered', 'filter', 'bool', 'must', esq.term('foo', 'bar'));
Generates
{
filtered: {
filter: {
bool: {
must: [
{
term: { foo: 'bar' }
}
]
}
}
}
}
Build a match query component using the key and value provided.
Example
esq.match('foo', 'bar');
Generates
{
match: {
foo: 'bar'
}
}
Build a term query component using the key and value provided.
Example
esq.term('foo', 'bar');
Generates
{
term: {
foo: 'bar'
}
}
Build a range query using the key, grater than equal and/or less than equal provided.
Example
esq.range('foo', 1, 5);
Generates
{
range: {
foo: {
gte: 1,
lte: 5
}
}
}
Build a wildcard query component using the key and value provided.
Example
esq.wildcard('foo', 'bar*');
Generates
{
wildcard: {
foo: {
value: 'bar*'
}
}
}
FAQs
Easily build elasticsearch queries
The npm package esq receives a total of 1,118 weekly downloads. As such, esq popularity was classified as popular.
We found that esq demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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 researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.