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.
Elasto is a simple library to query Elasticsearch.
npm install elasto
More infos about the config options here.
var Elasto = require('elasto');
Elasto.config({
host: 'localhost:9200',
});
Elasto provides a simple query interface for the common usecases. You can have access to the elasticsearch.js client via Elasto.client
.
The client gets instantiated when you set the config with a host.
All-in-one example. Find more options on API.
Elasto.query({
index: 'development',
type: 'tweets'
})
.near({ // documents near this location
lat: 51.5,
lon: -0.1467912,
radius: 3
})
.where('name', 'London') // where name matches London
.size(2) // return only 2 documents
.from(1) // skip 1 document (searching after 1 document)
.fields('name', 'address') // return only name and address fields
.exec()
.then(function (res) { // execute
// done!
});
Elasto.query({
index: 'development',
type: 'tweets'
})
.exec();
.where
.where
accepts two types of arguments. Either an object with the fields to match.
Elasto.query({
index: 'development',
type: 'tweets'
})
.where({ username: '@jack'})
.exec();
Or key value pair of arguments
Elasto.query({
index: 'development',
type: 'tweets'
})
.where('username', '@jack')
.exec();
.term
Search a term.
Elasto.query({
index: 'development',
type: 'tweets'
})
.term('#love')
.exec();
.size
.limit
Limit the size of the query.
Elasto.query({
index: 'development',
type: 'tweets'
})
.limit(3)
.exec();
.sort
.limit
Sorts the query by a field the size of the query.
Elasto.query({
index: 'development',
type: 'tweets'
})
.sort('description', 'asc')
.exec();
You can also sort by distance. It will sort based on the location
field in the document.
Elasto.query({
index: 'development',
type: 'tweets'
})
.sort('distance', {
lat: 51.5,
lon: -0.1467912,
})
.exec();
.near
Finds documents in an area. The radius is in miles.
Elasto.query({
index: 'development',
type: 'tweets'
})
.near({
lat: 51.5,
lon: -0.1467912,
radius: 2
})
.exec();
.from
.offset
Skips documents in the query.
Elasto.query({
index: 'development',
type: 'tweets'
})
.from(3)
.exec();
.range
Find documents where the field matches a range.
Elasto.query({
index: 'development',
type: 'tweets'
})
.range('characters', [120, 150])
.exec();
You can also query the distance range. It will sort based on the location
field in the document. All the distances are in miles.
Elasto.query({
index: 'development',
type: 'tweets'
})
.range('distance', {
lat: 51.5,
lon: -0.1467912,
from: 2,
to: 3
})
.exec();
.fields
Only return the specific fields.
Elasto.query({
index: 'development',
type: 'tweets'
})
.fields(['name', 'id'])
.exec();
.exclude
.not
Excludes documents where the query gets matched (opposite of .where
).
Elasto.query({
index: 'development',
type: 'tweets'
})
.not('username', '@hater666')
.exec();
Count documents based on a query
Elasto.query({
index: 'development',
type: 'tweets'
})
.count();
elasto
is released under the MIT license. See LICENSE.txt
for the complete text.
FAQs
ElasticSearch client
The npm package elasto receives a total of 0 weekly downloads. As such, elasto popularity was classified as not popular.
We found that elasto 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’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.