npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@amitphulera/easyes

v1.1.0

Published

Library to simplify elastic search operations easy.

Downloads

7

Readme

EasyES

Provides an interface to query from ElasticSearch using the latest ElasticSearch SDK.

It is built for a special usecase, to translate sails like queries to elastic search and get custom results. The parameters used in the library serves a special usecase that I my team are currently working on. In future, I have plans to generalise this library and which will be suitable for basic elastic search querying and indexing. The plan is that developer should only focus on "what" he needs rather then "how" to get it. The library should be intelligent to use the best possible way to retrieve data from elastic search.

The data structures for which this is built are present in tests/mockData directory.

Use

  • Installation
npm i @amitphulera/easyes
  • Intialization
const {EasyES} = require('@amitphulera/easyes');
// Iniitialise with you AWS elasticsearch domain and region
const es = new EasyES(
    'https://some-elasticsearchcluster-somerandomid.us-west-2.es.amazonaws.com',
    'us-west-2',
);

Methods

  • query(searchObj, options) : Queries elastic search on the basis of search object provided. Will return upto 10k matching results by default, if size is not specified. If you want to get all the results then set size to -1 and please mind that only 10 thousand elements can be returned after setting to -1.

    • searchObj sails-dynamo like query object
    • filters other options to pass to elastic search for the query The following filters are avaialable as of present
      • filters.size defaults to 10000
      • filters.sort defaults to asc
      • filters.format defaults to 'datadevice'. raw|flatten|dataDevice|tsDevParamMap dataDevice : The results are structured like datadevice output which basically is all the parameters will be wrapped in data key by default, if you need flattened response set it to true. raw : If you want raw elastic search response then set this variable to true. This will dominate over flatten, and flatten will be ignored if this parameter is set to true flatten : Will return you flattened results tsDevParamMap : A map containing timestamp as primary key then indexed by deviceId then by parameter
    {
    <timestamp>:
       <deviceId>:{
         <paramA>:<val>,
         <paramB>:<val>
        }
    }
  • lastKnownParamValue(siteId, timestamp, deviceId, field) : Queries elastic serach to get the last known value of parameter specified in field before the timestamp. Let say we want to get the last kvah value before 10th august 2019 of a particular deviceId then this function can be used.

  • indexRecords(records) : Takes an array of records and indexes them in elasticsearch using bulk API call. The function returns a promise of the bulk API call of ElasticSearch which tries to index all the records.