Ember Data adapter that connects to a Solr server.
$ ember install:addon ember-solr
This will create a new setting in config/environment.js. Replace
the default value with your Solr server.
$ 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.
Additional documentation is available at http://chris.eldredge.io/ember-solr/latest/.
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.
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.
$ 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 |
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".
config/environment.js sets the URL of the Solr server.
SolrAdapter has the following properties:
-
baseURLusually injected fromconfig/environment -
commit(Default:EmberSolr.CommitType.None) include commit command in updates -
commitWithinMilliseconds(Default:undefined) includecommitWithinin updates -
dataType(Default:jsonp) chooses normaljsonorjsonpto side-step cross origin restrictions -
defaultCorespecify a Solr Core to route requests to by default -
defaultSerializer(Default:-solr) -
enableRealtimeGet(Default:false) use Solr's RealTimeGetHandler when applicable -
updateMode(Default:EmberSolr.SolrUpdateMode.None) enables optimistic concurrency by sending appropriate_version_on updatesSolrAdapteralso has these methods that can be overridden: -
coreForTypechoose another Solr Core for a given type -
filterQueryForTypecreate an optional filter query to filter documents -
handlerForTypeselect a Solr request handler path and type for an operation -
uniqueKeyForTypeoverride the canonicalidfield with something else
See SolrAdapter.
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.
git clonethis repositorynpm install -g ember-cli bowerember install
ember test
For more information on using ember-cli, visit http://www.ember-cli.com/.