[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-7878":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":16,"stars30d":17,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":18,"rankGlobal":10,"rankLanguage":10,"license":19,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":22,"hasPages":20,"topics":23,"createdAt":10,"pushedAt":10,"updatedAt":30,"readmeContent":31,"aiSummary":32,"trendingCount":16,"starSnapshotCount":16,"syncStatus":17,"lastSyncTime":33,"discoverSource":34},7878,"elasticsearch-rails","elastic\u002Felasticsearch-rails","elastic","Elasticsearch integrations for ActiveModel\u002FRecord and Ruby on Rails","",null,"Ruby",3085,800,377,39,0,2,30.71,"Apache License 2.0",false,"main",true,[24,25,7,26,27,28,29],"activemodel","activerecord","elasticsearch","rails","ruby","ruby-on-rails","2026-06-12 02:01:45","# Elasticsearch Rails\n\n[![Ruby tests](https:\u002F\u002Fgithub.com\u002Felastic\u002Felasticsearch-rails\u002Factions\u002Fworkflows\u002Ftests.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Felastic\u002Felasticsearch-rails\u002Factions\u002Fworkflows\u002Ftests.yml)\n[![JRuby tests](https:\u002F\u002Fgithub.com\u002Felastic\u002Felasticsearch-rails\u002Factions\u002Fworkflows\u002Fjruby.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Felastic\u002Felasticsearch-rails\u002Factions\u002Fworkflows\u002Fjruby.yml)\n\nThis repository contains various Ruby and Rails integrations for [Elasticsearch](http:\u002F\u002Felasticsearch.org):\n\n* ActiveModel integration with adapters for ActiveRecord and Mongoid\n* _Repository pattern_ based persistence layer for Ruby objects\n* Enumerable-based wrapper for search results\n* ActiveRecord::Relation-based wrapper for returning search results as records\n* Convenience model methods such as `search`, `mapping`, `import`, etc\n* Rake tasks for importing the data\n* Support for Kaminari and WillPaginate pagination\n* Integration with Rails' instrumentation framework\n* Templates for generating example Rails application\n\nElasticsearch client and Ruby API is provided by the\n**[elasticsearch-ruby](https:\u002F\u002Fgithub.com\u002Felastic\u002Felasticsearch-ruby)** project.\n\n## Installation\n\nInstall each library from [Rubygems](https:\u002F\u002Frubygems.org\u002Fgems\u002Felasticsearch):\n\n    gem install elasticsearch-model\n    gem install elasticsearch-rails\n\n## Compatibility\n\nThe libraries are compatible with Ruby 3.0 and higher.\n\nWe follow Ruby’s own maintenance policy and officially support all currently maintained versions per [Ruby Maintenance Branches](https:\u002F\u002Fwww.ruby-lang.org\u002Fen\u002Fdownloads\u002Fbranches\u002F).\n\nThe version numbers follow the Elasticsearch major versions. Currently the `main` branch is compatible with version `8.x` of the Elasticsearch stack.\n\n| Rubygem       |   | Elasticsearch |\n|:-------------:|:-:| :-----------: |\n| 0.1           | → | 1.x           |\n| 2.x           | → | 2.x           |\n| 5.x           | → | 5.x           |\n| 6.x           | → | 6.x           |\n| 7.x           | → | 7.x           |\n| 8.x           | → | 8.x           |\n| main          | → | 8.x           |\n\nCheck out [Elastic product end of life dates](https:\u002F\u002Fwww.elastic.co\u002Fsupport\u002Feol) to learn which releases are still actively supported and tested.\n\n## Usage\n\nThis project is split into three separate gems:\n\n* [**`elasticsearch-model`**](https:\u002F\u002Fgithub.com\u002Felastic\u002Felasticsearch-rails\u002Ftree\u002Fmain\u002Felasticsearch-model),\n  which contains search integration for Ruby\u002FRails models such as ActiveRecord::Base and Mongoid,\n\n* [**`elasticsearch-persistence`**](https:\u002F\u002Fgithub.com\u002Felastic\u002Felasticsearch-rails\u002Ftree\u002Fmain\u002Felasticsearch-persistence),\n  which provides a standalone persistence layer for Ruby\u002FRails objects and models\n\n* [**`elasticsearch-rails`**](https:\u002F\u002Fgithub.com\u002Felastic\u002Felasticsearch-rails\u002Ftree\u002Fmain\u002Felasticsearch-rails),\n  which contains various features for Ruby on Rails applications\n\nExample of a basic integration into an ActiveRecord-based model:\n\n```ruby\nrequire 'elasticsearch\u002Fmodel'\n\nclass Article \u003C ActiveRecord::Base\n  include Elasticsearch::Model\n  include Elasticsearch::Model::Callbacks\nend\n\n# Index creation right at import time is not encouraged.\n# Typically, you would call create_index! asynchronously (e.g. in a cron job)\n# However, we are adding it here so that this usage example can run correctly.\nArticle.__elasticsearch__.create_index!\nArticle.import\n\n@articles = Article.search('foobar').records\n```\n\nYou can generate a simple Ruby on Rails application with a single command\n(see the [other available templates](https:\u002F\u002Fgithub.com\u002Felastic\u002Felasticsearch-rails\u002Ftree\u002Fmain\u002Felasticsearch-rails#rails-application-templates)). You'll need to have an Elasticsearch cluster running on your system before generating the app. The easiest way of getting this set up is by running it with Docker with this command:\n\n```bash\n  docker run \\\n    --name elasticsearch-rails-searchapp \\\n    --publish 9200:9200 \\\n    --env \"discovery.type=single-node\" \\\n    --env \"cluster.name=elasticsearch-rails\" \\\n    --env \"cluster.routing.allocation.disk.threshold_enabled=false\" \\\n    --rm \\\n    docker.elastic.co\u002Felasticsearch\u002Felasticsearch:7.6.0\n```\n\nOnce Elasticsearch is running, you can generate the simple app with this command:\n\n```bash\nrails new searchapp --skip --skip-bundle --template https:\u002F\u002Fraw.github.com\u002Felasticsearch\u002Felasticsearch-rails\u002Fmain\u002Felasticsearch-rails\u002Flib\u002Frails\u002Ftemplates\u002F01-basic.rb\n```\n\nExample of using Elasticsearch as a repository for a Ruby domain object:\n\n```ruby\nclass Article\n  attr_accessor :title\nend\n\nrequire 'elasticsearch\u002Fpersistence'\nrepository = Elasticsearch::Persistence::Repository.new\n\nrepository.save Article.new(title: 'Test')\n# POST http:\u002F\u002Flocalhost:9200\u002Frepository\u002Farticle\n# => {\"_index\"=>\"repository\", \"_id\"=>\"Ak75E0U9Q96T5Y999_39NA\", ...}\n```\n\n**Please refer to each library documentation for detailed information and examples.**\n\n### Model\n\n* [[README]](https:\u002F\u002Fgithub.com\u002Felastic\u002Felasticsearch-rails\u002Fblob\u002Fmain\u002Felasticsearch-model\u002FREADME.md)\n* [[Documentation]](http:\u002F\u002Frubydoc.info\u002Fgems\u002Felasticsearch-model\u002F)\n* [[Test Suite]](https:\u002F\u002Fgithub.com\u002Felastic\u002Felasticsearch-rails\u002Ftree\u002Fmain\u002Felasticsearch-model\u002Fspec\u002Felasticsearch\u002Fmodel)\n\n### Persistence\n\n* [[README]](https:\u002F\u002Fgithub.com\u002Felastic\u002Felasticsearch-rails\u002Fblob\u002Fmain\u002Felasticsearch-persistence\u002FREADME.md)\n* [[Documentation]](http:\u002F\u002Frubydoc.info\u002Fgems\u002Felasticsearch-persistence\u002F)\n* [[Test Suite]](https:\u002F\u002Fgithub.com\u002Felastic\u002Felasticsearch-rails\u002Ftree\u002Fmain\u002Felasticsearch-persistence\u002Fspec)\n\n### Rails\n\n* [[README]](https:\u002F\u002Fgithub.com\u002Felastic\u002Felasticsearch-rails\u002Fblob\u002Fmain\u002Felasticsearch-rails\u002FREADME.md)\n* [[Documentation]](http:\u002F\u002Frubydoc.info\u002Fgems\u002Felasticsearch-rails)\n* [[Test Suite]](https:\u002F\u002Fgithub.com\u002Felastic\u002Felasticsearch-rails\u002Ftree\u002Fmain\u002Felasticsearch-rails\u002Fspec)\n\n## Development\n\nTo work on the code, clone the repository and install all dependencies first:\n\n```\ngit clone https:\u002F\u002Fgithub.com\u002Felastic\u002Felasticsearch-rails.git\ncd elasticsearch-rails\u002F\nbundle install\nrake bundle:install\n```\n\n### Running the Test Suite\n\nYou can run unit and integration tests for each sub-project by running the respective Rake tasks in their folders.\n\nYou can also unit, integration, or both tests for all sub-projects from the top-level directory:\n\n    rake test:all\n\nThe test suite expects an Elasticsearch cluster running on port 9250, and **will delete all the data**.\n\n## License\n\nThis software is licensed under the Apache 2 license, quoted below.\n\n    Licensed to Elasticsearch B.V. under one or more contributor\n    license agreements. See the NOTICE file distributed with\n    this work for additional information regarding copyright\n    ownership. Elasticsearch B.V. licenses this file to you under\n    the Apache License, Version 2.0 (the \"License\"); you may\n    not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n    \thttp:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing,\n    software distributed under the License is distributed on an\n    \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n    KIND, either express or implied.  See the License for the\n    specific language governing permissions and limitations\n    under the License.\n","这个项目提供了Elasticsearch与ActiveModel\u002FRecord以及Ruby on Rails的集成。它通过ActiveModel适配器支持ActiveRecord和Mongoid，实现了基于仓库模式的对象持久层、搜索结果的可枚举封装及ActiveRecord::Relation风格的结果处理。此外，还提供了便捷的模型方法如`search`、`mapping`、`import`等，并集成了Kaminari和WillPaginate分页功能，支持Rails框架下的性能监控。适用于需要在Ruby或Rails应用中高效利用Elasticsearch进行数据索引、搜索及分析的场景。","2026-06-11 03:14:53","top_language"]