{"_id":"@atelierfabien/loopback-connector-es","_rev":"5-24a876801f36a117089f2b99cde55532","name":"@atelierfabien/loopback-connector-es","dist-tags":{"latest":"0.3.2"},"versions":{"0.3.2":{"name":"@atelierfabien/loopback-connector-es","version":"0.3.2","keywords":["loopback","elastic","elasticsearch","es","loopback-connector","connector"],"author":{"name":"Drakerian"},"license":{"url":"https://github.com/strongloop-community/loopback-connector-elastic-search/blob/master/LICENCE","name":"MIT"},"_id":"@atelierfabien/loopback-connector-es@0.3.2","maintainers":[{"name":"atelierfabien","email":"info@atelierfabien.be"}],"contributors":[{"name":"Pulkit Singhal","email":"pulkit@shoppinpal.com"},{"name":"yagobski"}],"homepage":"https://github.com/strongloop-community/loopback-connector-elastic-search","bugs":{"url":"https://github.com/strongloop-community/loopback-connector-elastic-search/issues"},"dist":{"shasum":"96a4429583693b0aef779263331e3fb28a58f4f0","tarball":"https://registry.npmjs.org/@atelierfabien/loopback-connector-es/-/loopback-connector-es-0.3.2.tgz","integrity":"sha512-R5DP+7rGp+puXsY2NmESG+PQm/7XWE9TKIdBuYixdoHfK82qJU3msQ1mGr+0PKMs5cr/6t0UKydwdWrBGjAivA==","signatures":[{"sig":"MEUCIQCdYKfn+VfWcc2ZKLM/0OhQ0ec8XHIFrakkyeXQlQ5WPwIgB99p5WSLMSegfooogKhxuyCuavLFTi0BPJLMRekosKQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","_shasum":"96a4429583693b0aef779263331e3fb28a58f4f0","gitHead":"e31bb4964bc3640a8a416160aded940f71bcb88f","scripts":{"test":"test"},"_npmUser":{"name":"atelierfabien","email":"info@atelierfabien.be"},"repository":{"url":"git+https://github.com/strongloop-community/loopback-connector-elastic-search.git","type":"git"},"_npmVersion":"2.15.10","description":"Connect LoopBack to Elasticsearch engine","directories":{"test":"test","example":"examples"},"_nodeVersion":"4.2.2","dependencies":{"async":"^1.5.0","debug":"^2.1.3","lodash":"^3.5.0","bluebird":"^2.9.14","elasticsearch":"^9.0.0","loopback-connector":"^2.3.0"},"devDependencies":{"chai":"^2.1.2","grunt":"^0.4.5","mocha":"^1.21.4","should":"^5.2.0","grunt-mocha-test":"^0.12.1","loopback-datasource-juggler":"^2.21.0"},"_npmOperationalInternal":{"tmp":"tmp/loopback-connector-es-0.3.2.tgz_1473269792492_0.26916091423481703","host":"packages-16-east.internal.npmjs.com"}}},"time":{"created":"2016-09-07T17:36:33.730Z","modified":"2026-03-12T17:43:42.474Z","0.3.2":"2016-09-07T17:36:33.730Z"},"bugs":{"url":"https://github.com/strongloop-community/loopback-connector-elastic-search/issues"},"author":{"name":"Drakerian"},"license":{"url":"https://github.com/strongloop-community/loopback-connector-elastic-search/blob/master/LICENCE","name":"MIT"},"homepage":"https://github.com/strongloop-community/loopback-connector-elastic-search","keywords":["loopback","elastic","elasticsearch","es","loopback-connector","connector"],"repository":{"url":"git+https://github.com/strongloop-community/loopback-connector-elastic-search.git","type":"git"},"description":"Connect LoopBack to Elasticsearch engine","contributors":[{"name":"Pulkit Singhal","email":"pulkit@shoppinpal.com"},{"name":"yagobski"}],"maintainers":[{"email":"info@atelierfabien.be","name":"vorm-labs"}],"readme":"# loopback-connector-elastic-search\n\n[![Join the chat at https://gitter.im/strongloop-community/loopback-connector-elastic-search](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/strongloop-community/loopback-connector-elastic-search?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)\n\nBasic Elasticsearch datasource connector for [Loopback](http://strongloop.com/node-js/loopback/).\n\n<!-- START doctoc generated TOC please keep comment here to allow auto update -->\n<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->\n**Table of Contents**  *generated with [DocToc](https://github.com/thlorenz/doctoc)*\n\n- [loopback-connector-elastic-search](#loopback-connector-elastic-search)\n  - [Install connector from NPM](#install-connector-from-npm)\n  - [Configuring connector](#configuring-connector)\n    - [Required:](#required)\n    - [Optional:](#optional)\n  - [Run example](#run-example)\n  - [Hosted ElasticSearch](#hosted-elasticsearch)\n  - [Release notes](#release-notes)\n\n<!-- END doctoc generated TOC please keep comment here to allow auto update -->\n\n## Install connector from NPM\n\n    npm install loopback-connector-es --save\n\n## Configuring connector\n\n1 . Edit **datasources.json** and set:\n\n  ```\n\"<ConnectorEntry>\": {\n    \"connector\": \"es\",\n    \"name\": \"<name>\",\n    \"index\": \"<index>\",\n    \"hosts\": [\n          {\n            \"protocol\": \"http\",\n            \"host\": \"127.0.0.1\",\n            \"port\": 9200,\n            \"auth\": \"username:password\"\n          }\n    ],\n    \"apiVersion\": \"<apiVersion>\",\n    \"log\": \"trace\",\n    \"defaultSize\": <defaultSize>,\n    \"requestTimeout\": 30000,\n    \"ssl\": {\n        \"ca\": \"./../cacert.pem\",\n        \"rejectUnauthorized\": true\n    },\n    \"mappings\": [\n        {\n            \"name\": \"UserModel\",\n            \"properties\": {\n                \"realm\": {\"type\": \"string\", \"index\" : \"not_analyzed\" },\n                \"username\": {\"type\": \"string\", \"index\" : \"not_analyzed\" },\n                \"password\": {\"type\": \"string\", \"index\" : \"not_analyzed\" },\n                \"email\": {\"type\": \"string\", \"index\" : \"not_analyzed\" }\n            }\n        }\n    ]\n}\n  ```\n2. You can peek at `/examples/server/datasources.json` for more hints.\n3. Services that provide ES as a hosted solution and offer an indefinite free plan for tinkering with ES:\n  1. https://app.bonsai.io/plans\n    * $0 per month\n    * 1GB memory, 1GB storage\n    * no CC required\n  2. https://facetflow.com/#plans\n    * $0/month\n    * 5,000 documents, 500 MB storage\n    * 1 primary shard, 0 replicas\n    * Sandbox (not for production use)\n  3. `Free + Hosted` translates to quick success in the quest to learn ES.\n\n### Required:\n- **host:** Elasticsearch engine host address.\n- **port:** Elasticsearch engine port.\n- **name:** Connector name.\n- **connector:** Elasticsearch driver.\n- **index:** Search engine specific index.\n\n### Optional:\n- **apiVersion:** specify the major version of the Elasticsearch nodes you will be connecting to.\n- **log:** logging option.\n- **defaultSize:** total number of results to return per page.\n- **requestTimeout:** this value is in milliseconds\n- **ssl:** useful for setting up a secure channel\n- **protocol:** can be `http` or `https` (`http` is the default if none specified) ... *must* be `https` if you're using `ssl` \n- **auth**: useful if you have access control setup via services like `es-jetty` or `found` or `shield`\n- **mappings:** an array of elasticsearch mappings for your various loopback models\n\n## Run example\n\n1. Install dependencies and start the example server\n\n  ```\n  git clone https://github.com/strongloop-community/loopback-connector-elastic-search.git myEsConnector\n  cd myEsConnector/examples\n  npm install\n  ```\n2. [Configure the connector](#configuring-connector)\n  * Don't forget to create an index in your ES instance: `curl -X POST https://username:password@my.es.cluster.com/shakespeare`\n  * If you mess up and want to delete, you can use: `curl -X DELETE https://username:password@my.es.cluster.com/shakespeare`\n3. Set up a `cacert.pem` file for communicating securely (https) with your ES instance. Download the certificate chain for your ES server using this **sample** (will need to be edited to *use* your provider) command:\n\n  ```\n  cd myEsConnector\n  openssl s_client -connect my.es.cluster.com:9243 -showcerts | tee cacert.pem\n  ```\n  It will be saved at the base of your cloned project.\n4. Run:\n\n  ```\n  cd myEsConnector/examples\n  DEBUG=boot:test:* node server/server.js\n  ```\n  * The `examples/server/boot/boot.js` file will automatically populate data for UserModels on your behalf when the server starts.\n5. Open this URL in your browser: [http://localhost:3000/explorer](http://localhost:3000/explorer)\n  * Try fetching all the users via the rest api console\n  * You can dump all the data from your ES index, via cmd-line too: `curl -X POST username:password@my.es.cluster.com/shakespeare/_search -d '{\"query\": {\"match_all\": {}}}'`\n6. To test a specific filter via GET method, use for example: `{\"q\" : \"friends, romans, countrymen\"}`\n\n## Hosted ElasticSearch\nServices that provide ES as a hosted solution and offer an indefinite free plan for tinkering with ES:\n  1. https://app.bonsai.io/plans\n    * $0 per month\n    * 1GB memory, 1GB storage\n    * no CC required\n  2. https://facetflow.com/#plans\n    * $0/month\n    * 5,000 documents, 500 MB storage\n    * 1 primary shard, 0 replicas\n    * Sandbox (not for production use)\n  3. `Free + Hosted` translates to quick success in the quest to learn ES.\n\n## Release notes\n\n  * For this connector, you can configure an `index` name for your ES instance and the loopback model's name is conveniently/automatically mapped as the ES `type`.\n  * Users must setup `string` fields as `not_analyzed` by default for predictable matches just like other loopback backends. And if more flexibility is required, multi-field mappings can be used too.\n\n    ```\n    \"name\" : {\n        \"type\" : \"multi_field\",\n        \"fields\" : {\n            \"name\" : {\"type\" : \"string\", \"index\" : \"not_analyzed\"},\n            \"native\" : {\"type\" : \"string\", \"index\" : \"analyzed\"}\n        }\n    }\n    ...\n    // this will treat 'George Harrison' as 'George Harrison' in a search\n    User.find({order: 'name'}, function (err, users) {..}\n    // this will treat 'George Harrison' as two tokens: 'george' and 'harrison' in a search\n    User.find({order: 'name', where: {'name.native': 'Harrison'}}, function (err, users) {..}\n    ```\n  * TBD\n","readmeFilename":"README.md"}