|
| 1 | +![[email protected]](http://i.imgur.com/RIvu9.png) |
| 2 | + |
| 3 | +# waterline-elasticsearch |
| 4 | + |
| 5 | +Provides easy access to `elasticsearch` from Sails.js & Waterline. |
| 6 | + |
| 7 | +This module is a Waterline/Sails adapter, an early implementation of a rapidly-developing, tool-agnostic data standard. Its goal is to provide a set of declarative interfaces, conventions, and best-practices for integrating with all sorts of data sources. Not just databases-- external APIs, proprietary web services, or even hardware. |
| 8 | + |
| 9 | +Strict adherence to an adapter specification enables the (re)use of built-in generic test suites, standardized documentation, reasonable expectations around the API for your users, and overall, a more pleasant development experience for everyone. |
| 10 | + |
| 11 | + |
| 12 | +### Installation |
| 13 | + |
| 14 | +To install this adapter, run: |
| 15 | + |
| 16 | +```sh |
| 17 | +$ npm install waterline-elasticsearch |
| 18 | +``` |
| 19 | + |
| 20 | + |
| 21 | +### Configuration |
| 22 | + |
| 23 | +```js |
| 24 | +{ |
| 25 | + adapter: 'sails-elasticsearch', |
| 26 | + hosts: ['http://127.0.0.1:9200'], |
| 27 | + keepAlive: false, |
| 28 | + sniffOnStart: true, |
| 29 | + maxRetries: 10, |
| 30 | + deadTimeout: 40000, |
| 31 | + sniffOnConnectionFault: true, |
| 32 | + apiVersion: '1.3' |
| 33 | +}, |
| 34 | +``` |
| 35 | + |
| 36 | + |
| 37 | +### Usage |
| 38 | + |
| 39 | +This adapter exposes the following methods: |
| 40 | + |
| 41 | +###### `search()` |
| 42 | + |
| 43 | ++ **Status** |
| 44 | + + Done |
| 45 | + |
| 46 | +###### `createIndex()` |
| 47 | + |
| 48 | ++ **Status** |
| 49 | + + Done |
| 50 | + |
| 51 | +###### `updateIndex()` |
| 52 | + |
| 53 | ++ **Status** |
| 54 | + + Done |
| 55 | + |
| 56 | +###### `destroyIndex()` |
| 57 | + |
| 58 | ++ **Status** |
| 59 | + + Done |
| 60 | + |
| 61 | +###### `countIndex()` |
| 62 | + |
| 63 | ++ **Status** |
| 64 | + + Done |
| 65 | + |
| 66 | +###### `bulk()` |
| 67 | + |
| 68 | ++ **Status** |
| 69 | + + Done |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | +### Interfaces |
| 74 | + |
| 75 | +>TODO: |
| 76 | +>Specify the interfaces this adapter will support. |
| 77 | +>e.g. `This adapter implements the [semantic]() and [queryable]() interfaces.` |
| 78 | +> For more information, check out this repository's [FAQ](./FAQ.md) and the [adapter interface reference](https://github.com/balderdashy/sails-docs/blob/master/adapter-specification.md) in the Sails docs. |
| 79 | +
|
| 80 | + |
| 81 | +### Development |
| 82 | + |
| 83 | +Check out **Connections** in the Sails docs, or see the `config/connections.js` file in a new Sails project for information on setting up adapters. |
| 84 | + |
| 85 | +## Getting started |
| 86 | +It's usually pretty easy to add your own adapters for integrating with proprietary systems or existing open APIs. For most things, it's as easy as `require('some-module')` and mapping the appropriate methods to match waterline semantics. To get started: |
| 87 | + |
| 88 | +1. Fork this repository |
| 89 | +2. Set up your `README.md` and `package.json` file. Sails.js adapter module names are of the form sails-*, where * is the name of the datastore or service you're integrating with. |
| 90 | +3. Build your adapter. |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | +### Running the tests |
| 96 | + |
| 97 | +Configure the interfaces you plan to support (and targeted version of Sails/Waterline) in the adapter's `package.json` file: |
| 98 | + |
| 99 | +```javascript |
| 100 | +{ |
| 101 | + //... |
| 102 | + "sails": { |
| 103 | + "adapter": { |
| 104 | + "sailsVersion": "~0.10.0", |
| 105 | + "implements": [ |
| 106 | + "semantic", |
| 107 | + "queryable" |
| 108 | + ] |
| 109 | + } |
| 110 | + } |
| 111 | +} |
| 112 | +``` |
| 113 | + |
| 114 | +In your adapter's directory, run: |
| 115 | + |
| 116 | +```sh |
| 117 | +$ npm test |
| 118 | +``` |
| 119 | + |
| 120 | + |
| 121 | +## Publish your adapter |
| 122 | + |
| 123 | +> You're welcome to write proprietary adapters and use them any way you wish-- |
| 124 | +> these instructions are for releasing an open-source adapter. |
| 125 | +
|
| 126 | +1. Create a [new public repo ](https://github.com/new) and add it as a remote (`git remote add origin [email protected]:yourusername/sails-youradaptername.git) |
| 127 | +2. Make sure you attribute yourself as the author and set the license in the package.json to "MIT". |
| 128 | +3. Run the tests one last time. |
| 129 | +4. Do a [pull request to sails-docs](https://github.com/balderdashy/sails-docs/compare/) adding your repo to `data/adapters.js`. Please let us know about any special instructions for usage/testing. |
| 130 | +5. We'll update the documentation with information about your new adapter |
| 131 | +6. Then everyone will adore you with lavish praises. Mike might even send you jelly beans. |
| 132 | + |
| 133 | +7. Run `npm version patch` |
| 134 | +8. Run `git push && git push --tags` |
| 135 | +9. Run `npm publish` |
| 136 | + |
| 137 | + |
| 138 | + |
| 139 | + |
| 140 | +### Questions? |
| 141 | + |
| 142 | +See [`FAQ.md`](./FAQ.md). |
| 143 | + |
| 144 | + |
| 145 | + |
| 146 | +### More Resources |
| 147 | + |
| 148 | +- [Stackoverflow](http://stackoverflow.com/questions/tagged/sails.js) |
| 149 | +- [#sailsjs on Freenode](http://webchat.freenode.net/) (IRC channel) |
| 150 | +- [Twitter](https://twitter.com/sailsjs) |
| 151 | +- [Professional/enterprise](https://github.com/balderdashy/sails-docs/blob/master/FAQ.md#are-there-professional-support-options) |
| 152 | +- [Tutorials](https://github.com/balderdashy/sails-docs/blob/master/FAQ.md#where-do-i-get-help) |
| 153 | +- <a href="http://sailsjs.org" target="_blank" title="Node.js framework for building realtime APIs."><img src="https://github-camo.global.ssl.fastly.net/9e49073459ed4e0e2687b80eaf515d87b0da4a6b/687474703a2f2f62616c64657264617368792e6769746875622e696f2f7361696c732f696d616765732f6c6f676f2e706e67" width=60 alt="Sails.js logo (small)"/></a> |
| 154 | + |
| 155 | + |
| 156 | +### License |
| 157 | + |
| 158 | +**[MIT](./LICENSE)** |
| 159 | +© 2014 [balderdashy](http://github.com/balderdashy) & [contributors] |
| 160 | +[Mike McNeil](http://michaelmcneil.com), [Balderdash](http://balderdash.co) & contributors |
| 161 | + |
| 162 | +[Sails](http://sailsjs.org) is free and open-source under the [MIT License](http://sails.mit-license.org/). |
| 163 | + |
| 164 | + |
| 165 | +[](http://githalytics.com/balderdashy/waterline-elasticsearch/README.md) |
| 166 | + |
| 167 | + |
0 commit comments