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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ember-es-adapter

v0.0.8

Published

An elasticsearch adapter for EmberJS.

Readme

Ember-ES-Adapter

Build Status npm version Ember Observer Score Code Climate

An adapter written for Elasticsearch and EmberJS.

Demo

S3 Blog, this shows just the basics. The repo can be found here: ember-s3-blog. This is very much a work in progress, but allows me to have a use-case to build the adapter.

On the hotplate for [0.1.0]

  • [ ] Add functionality to the Adapter
    • [ ] findMany
    • [ ] queryRecord
    • [-] updateRecord (partially implemented, not fully tested)
    • [x] createRecord
    • [x] deleteRecord (Already works with default)
    • [x] query
    • [x] findAll
  • [ ] Add functionality to the Serializer
    • [x] normalizeCreateRecordResponse (Already works with default)
    • [ ] normalizeDeleteRecordResponse
    • [ ] normalizeQueryRecordResponse
    • [x] normalizeResponse
    • [ ] normalizeUpdateRecordResponse
    • [x] normalizeFindAllResponse
    • [x] normalizeSingleResponse
    • [x] normalizeQueryResponse
    • [x] serialize (not a fan of this, but don't know a better way)
  • [ ] Blueprints
    • [ ] Adapter
    • [ ] Serializer
  • [ ] ES-Tools
    • [ ] QueryDSL
      • [ ] Add MoreLikeThis
      • [ ] Add Aggregations
      • [x] Add Query
        • [x] Add Default Param Override
        • [x] match()
        • [x] match_phrase()
        • [x] multi_match()
        • [x] common_terms()
        • [x] query_string()
        • [x] simple_query_string()
        • [x] term()
        • [x] terms()
        • [x] range()
        • [x] exists()
        • [x] prefix()
        • [x] wildcard()
        • [x] regexp()
        • [x] fuzzy()
        • [x] type()
        • [x] ids()
      • [x] Add Filter
        • [x] Add Default Param Override
      • [x] Add Highlighting
        • [x] Add Default Param Override
        • [x] Add fields
      • [x] Compound Query
        • [x] Add Bool (must, filter, should, must_not)
      • [x] Add sorts
      • [x] Add size
      • [x] Add from
      • [x] Allow params from route
      • [x] Add prototype for detecting page (pagination API)
      • [ ] Add full documentation (yui comments)
      • [x] Make it work
      • [x] Better Readme Examples
  • [ ] Make all the tests
    • [ ] The adapter
    • [ ] The serializer
    • [ ] The QueryDSL

The gameplan [0.1.5]

  • [ ] Add functionality to the Adapter
    • [ ] shouldReloadRecord (If needed)
    • [ ] shouldReloadAll (If needed)
  • [ ] Add functionality to the Serializer
    • [ ] normalizeArrayResponse
    • [ ] normalizeFindManyResponse
    • [ ] cleanup serialize
  • [ ] Instant Search Component
  • [ ] Blueprints
    • [ ] Adapter
    • [ ] Serializer
  • [ ] QueryDSL
    • [ ] Add ES versioning
  • [ ] Make all the tests
    • [ ] The extend utility
  • [ ] Definitely more...

How to use this

  • Adapter
`your_app/adapters/your_adapter.js`
import Es from 'ember-es-adapter/adapters/adapter';
import config from 'ember-get-config';

export default Es.extend({
  host: config.EsAdapter.host, 
  namespace: config.EsAdapter.namespace, 
});
  • Serializer
`your_app/serializers/your_serializer.js`
import Es from 'ember-es-adapter/serializer/serializer';
export default Es.extend({
});
  • In your app
`your_app/routes/index.js`
import { QueryDSL } from 'ember-es-adapter/utils/es-tools';

//let the adapter build the query
export default Ember.Route.extend({
  model(params) {
    //params['size'] = 2,
    //params['page'] = 2,
    return this.store.query('post', params);
  }
});

//OR build it yourself and send it on.
export default Ember.Route.extend({
  model(params) {
    //simulated params
    //if building yourself, these won't be utilized
    params['size'] = 10;
    params['query'] = 'yolo';


   /*  
     QueryDSL is chainable.
     .query({override}) will add a query, but if .bool() is used,
     it will replace the query with a bool type.
     the chaining works as long as a compound query is issued before it.
     (bool, highlight, filter, etc...)

   */

    let dsl = new QueryDSL(params);
    dsl.query({match_all:{}})
      .sort({'date':'desc'})
      .sort('title')

    or 

    dsl.query()
      .bool('must')
      .match('title': 'jerry'})
      .sort({'date':'desc'}) // sorts are agnostic to chains
      .sort('title')         // they are applied to the top level


    //building the query, sending to adapter
    params['esQuery'] = dsl.getQuery();
    return this.store.query('post', params);
  }
});

ElasticSearch QueryDSL Builder

  • Useage example

    import QueryDSL from "ember-es-adapter/utils/es-tools";
    let dsl = new QueryDSL({size: 2, from: 200});
    //  dsl = new QueryDSL(); // or no options
    
    dsl.query({'match': {"title": "Third"}}); //complex queries with no parsing
    dsl.query().match({'title':'Third'});   //same as above, just with chaining
    
    dsl.sort({'title':'asc'}); //add sort: can be complex
    dsl.title("title");        //add sort: or simple
    
    let query = es.getQuery();
  • Using the Query Builder

    import QueryDSL from 'ember-es-adapter/utils/es-tools';
    
    let es = new QueryDSL().query({match_all:{}});
  • Building a Query

    //Params
    .query({query})           // obj optional override the way you want it sent to ES.
    {
      query: {},            // object  
    } 
    
    import QueryDSL from 'ember-es-adapter/utils/es-tools';
    
    let dsl = new QueryDSL();
    
    //equivalent queries, latter allows for more complex queries
    dsl.query()
      .match({'title':'Third'});
    
    dsl.query({match:{'title':'Third'}});
    
        
    //example of using multiple bools within the same query.
    let dsl = new QueryDSL();
    dsl.query()
      .bool('must')
      .term({'user': 'steve'})
      .bool('filter')
      .range({'age': {"gte": 14, "lte": 35}})
  • Add a filter

    //Params
    .filter({obj})           // obj optional override the way you want it sent to ES.
    {
      obj: {},              // object  
    } 
    
    import QueryDSL from 'ember-es-adapter/utils/es-tools';
    
    let dsl = new QueryDSL();
    
    dsl.filter()
      .bool('must')
      .match({'title':'Third'});
    
  • Adding a Sort

    //Adds sort option. This can be ran multiple times if more specific sorts
    // are needed. 
    {
      sort: "title" || {},    // string || object  
    } 
    
    import QueryDSL from 'ember-es-adapter/utils/es-tools';
    
    let dsl = new esQuery();
    
    dsl.sort('title');
    dsl.sort({ "name": "asc" });
    dsl.sort({ "post_date": { "order": "asc"} });