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

ember-solr

v0.1.0

Published

Solr adapter for Ember Data

Downloads

6

Readme

ember-solr Build Status

Ember Data adapter that connects to a Solr server.

The SolrAdapter currently provides the read methods on DS.Adapter like find and findQuery.

Installing ember-solr with Ember CLI

$ ember install:addon ember-solr

This will create a new setting in config/environment.js. Replace the default value with your Solr server.

Using SolrAdapter

$ ember generate solr-adapter application [--enableRealTimeGet] [--url=http://example.com/solr/]

This will make a subclass of SolrAdapter for you to configure and register it as the application adapter.

See SolrAdapter for properties and methods you can override.

long, double and BigNumber

ember-solr uses a custom JSON parsing library to handle Solr long and double fields without losing precision on values that exceed Number.MAX_SAFE_INTEGER (2^53 - 1).

These values will be automatically detected and represented as instances of BigNumber using a string to represent the complete value.

No support is provided for performing arithmetic computations on BigNumber, such as addition, subtraction or multiplication.

JSON-P Limitations

By default, SolrAdapter.dataType is set to 'jsonp' to work with Solr servers that do not have CORS headers enabled. If you want to use Optimistic Concurrency or use long or double fields in your schema, JSON-P will not be able to handle values that exceed JavaScript's Number.MAX_SAFE_INTEGER (2^53 - 1).

In particular, this limitation means that using Solr's built-in _version_ field for optimistic concurrency is not possible with JSON-P.

Customizing Serialization

$ ember generate solr-serializer <name> [--dynamic] [--atomic] [--multiValued]

This will generate a serializer for a given model with some options.

Flag | Description ----------- | ----------- dynamic | Includes DynamicSerializerMixin atomic | Includes AtomicSerializerMixin multiValued | Includes AtomicMultiValuedSerializerMixin

Custom attribute types

This adapter registers the following types that map to Solr field types

Solr field type | DS.attr type --------------- | -------------- text | string double | BigNumber float | number int | number long | BigNumber strings | array of string numbers | array of number doubles | array of BigNumber floats | array of number ints | array of number longs | array of BigNumber booleans | array of boolean dates | array of date

The plural array types are intended for use with Solr fields that are multiValued="true".

Configuration

config/environment.js sets the URL of the Solr server.

SolrAdapter has the following properties:

  • baseURL usually injected from config/environment
  • dataType (Default: jsonp) chooses normal json or jsonp to side-step cross origin restrictions
  • defaultCore specify a Solr Core to route requests to by default
  • defaultSerializer (Default: -solr)
  • enableRealtimeGet (Default: false) use Solr's RealTimeGetHandler when applicable

SolrAdapter also has these methods that can be overridden:

  • coreForType choose another Solr Core for a given type
  • filterQueryForType create an optional filter query to filter documents
  • handlerForType select a Solr request handler path and type for an operation
  • uniqueKeyForType override the canonical id field with something else

Dynamic Fields

DynamicSerializerMixin provides a quick way to connect to a Solr server using Dynamic Fields.

Declare a model such as:

import DS from 'ember-data';

export default DS.Model.extend({
  title: DS.attr(),
  keywords: DS.attr('strings'),
  body: DS.attr('text'),
  popularity: DS.attr('float'),
  isPublic: DS.attr('boolean')
});

Then generate a serializer for your model:

ember g solr-serializer post --dynamic

The attributes on this model would be mapped, by default, to:

  • title => title_s
  • keywords => keywords_ss
  • body => body_txt
  • popularity: popularity_f
  • isPublic: is_public_b

See DynamicSerializerMixin for more on how to customize dynamic field names.

Contributing to ember-solr

Installation

  • git clone this repository
  • npm install -g ember-cli bower
  • ember install

Running Tests

  • ember test

For more information on using ember-cli, visit http://www.ember-cli.com/.