{"id":19020229,"url":"https://github.com/trailsjs/trailpack-elasticsearch","last_synced_at":"2025-04-23T05:26:07.615Z","repository":{"id":57378825,"uuid":"62741275","full_name":"trailsjs/trailpack-elasticsearch","owner":"trailsjs","description":":package: Elasticsearch Trailpack","archived":false,"fork":false,"pushed_at":"2017-11-14T09:38:06.000Z","size":13,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T07:55:04.143Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trailsjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-06T17:42:26.000Z","updated_at":"2024-03-07T07:33:40.000Z","dependencies_parsed_at":"2022-09-02T21:20:55.368Z","dependency_job_id":null,"html_url":"https://github.com/trailsjs/trailpack-elasticsearch","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trailsjs%2Ftrailpack-elasticsearch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trailsjs%2Ftrailpack-elasticsearch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trailsjs%2Ftrailpack-elasticsearch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trailsjs%2Ftrailpack-elasticsearch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trailsjs","download_url":"https://codeload.github.com/trailsjs/trailpack-elasticsearch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250375524,"owners_count":21420144,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T20:16:11.965Z","updated_at":"2025-04-23T05:26:07.559Z","avatar_url":"https://github.com/trailsjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# trailpack-elasticsearch\n:package: Elasticsearch Trailpack [https://www.elastic.co/products/elasticsearch](https://www.elastic.co/products/elasticsearch)\n\n[npm-image]: https://img.shields.io/npm/v/trailpack-elasticsearch.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/trailpack-elasticsearch\n[ci-image]: https://img.shields.io/travis/trailsjs/trailpack-elasticsearch/master.svg?style=flat-square\n[ci-url]: https://travis-ci.org/trailsjs/trailpack-elasticsearch\n[daviddm-image]: http://img.shields.io/david/trailsjs/trailpack-elasticsearch.svg?style=flat-square\n[daviddm-url]: https://david-dm.org/trailsjs/trailpack-elasticsearch\n[codeclimate-image]: https://img.shields.io/codeclimate/github/trailsjs/trailpack-elasticsearch.svg?style=flat-square\n[codeclimate-url]: https://codeclimate.com/github/trailsjs/trailpack-elasticsearch\n[gitter-image]: http://img.shields.io/badge/+%20GITTER-JOIN%20CHAT%20%E2%86%92-1DCE73.svg?style=flat-square\n[gitter-url]: https://gitter.im/trailsjs/trails\n\n[![Gitter][gitter-image]][gitter-url]\n[![NPM version][npm-image]][npm-url]\n[![Build status][ci-image]][ci-url]\n[![Dependency Status][daviddm-image]][daviddm-url]\n[![Code Climate][codeclimate-image]][codeclimate-url]\n\nProvides a simple integration with elasticseach\n\n## Usage\n\n###Configure\n\n```js\n// config/main.js\n\nmodule.exports = {\n\n  // ...\n  packs: [\n    require('trailpack-elasticsearch')\n  ]  \n}\n```\n\n### Configure connection\n\nConfiguration file for Elasticsearch trailpack is: `config/elasticsearch.js`\nOtherwise you could use `config/env/{env}.js` files with `elasticsearch` property\n\n```js\n\n// config/elasticsearch.js\n\nmodule.exports = {\n\n  connection: {\n    // List of hosts for elastic cluster\n    // hosts: [],\n\n    // One elastic instance host\n    host: 'localhost:9200',\n    // Log level\n    log: 'trace'\n  },\n\n  // Will validate if elastic connection is alive on Trails app start\n  validateConnection: true\n}\n```\n\n### Using Elasticsearch API\n\nThis trailpack creates an app propertry with elasticseach client. `app.elasticClient`\nSo you could use it whatever you want\n\n```js\n// api/controller/SomeController.js\nconst Controller = require('trails-controller')\n\nmodule.exports = class SomeController extends Controller {\n\n  someAction (request, reply) {\n    // Perform an action\n    this.app.elasticClient\n      .search({\n        q: 'something'\n      })\n      .then(function (body) {\n        const hits = body.hits.hits;\n      }, function (error) {\n        console.trace(error.message);\n      })\n  }\n}\n```\n\nMore information about Elasticsearch client could be found here: https://github.com/elastic/elasticsearch-js\n\n## Contributing\nWe love contributions! Please check out our [Contributor's Guide](https://github.com/trailsjs/trails/blob/master/CONTRIBUTING.md) for more\ninformation on how our projects are organized and how to get started.\n\n\n## License\n[MIT](https://github.com/trailsjs/trailpack-elasticsearch/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrailsjs%2Ftrailpack-elasticsearch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrailsjs%2Ftrailpack-elasticsearch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrailsjs%2Ftrailpack-elasticsearch/lists"}