In Java when using Hibernate Search for instance you bind JPA insertion, removal and update events to the search engine so that it automatically insert, updates and removes elements from the search engine index at the same time inserting, updating or removing it from the database. Is the same possible in Ruby and when using active record? Or do you manually have to register observers?
There are at least three notable gems allowing you to integrate Elasticsearch with ActiveRecord, some (like elasticsearch-rails, flex, retire) shipping with callback hooks for ActiveRecord that will automatically add, update or destroy an elasticsearch record on the appropriate actions.
elasticsearch-rails: The new default
flex: Really great wiki
stretcher: Runner-up, new option
All of them are actively maintained and developed. A still widely used but no longer maintained gem is retire.
retire: Widely used, but no longer supported
The Tire Rubygem comes with a robust ActiveModel/ActiveRecord integration.
The best option to quickly start is to generate an example Rails application:
rails new searchapp -m https://raw.github.com/karmi/tire/master/examples/rails-application-template.rb
Also, the Railscasts episode gives a quick overview of the integration. Tire README and integration test suite have all the information.
Related
there is any way to integrate the new Elasticsearch gem for ruby to rails, the tire was great but retired since two month and replaced by the new gem, however, no integrating functions with rails yet.
all the tutorial use tire, but now, how we can using rails with Elasticsearch?
A full-featured Rails integration is being worked on. If you want the high-level integration, and you don't want to provide it yourself, you can stick with Tire.
There is another gem called "searchkick" that integrates elasticsearch with Rails:
https://github.com/ankane/searchkick
It has some really cool features and can index data through rake tasks.
I have a minmimal implementation that I'm currently running for prototyping / evaluation of ElasticSearch, which has not thrown up any spanner in the works for a very focused prototyping run for the past 2 days ...
There's little or no error response checking yet, since our workloads heavily use Resque and we rely on Resque to capture and identify where we need to fine tune error handling.
https://gist.github.com/TobiG77/8610788
Couden't find any compare questions related to sunspot (Solr) to Elastic Search (Lucene)
What would be the pro's and con's on both search engines?
I saw other VS questions to get a better inside in the comparisment of 2 gems so hope this is allowed to get a better insight in the both engines for newbies ( like me ). I have looked at sunspot already but have some issues with it. So I searched
http://www.elasticsearch.org/guide/reference/api/
vs
http://sunspot.github.com/
I started working on a project that needed full text search in Ruby so naturally I started with Solr + Sunspot, but I couldn't get it to work. It was a pain just the get them connected, then tried to figure out if the document indexed correctly, figure out the runtime classpath so I can add additional analyzer/tokenizer classes, editing config.xml/schema.xml, etc. Solr numDocs clearly said it received and indexed them but I couldn't get any query results. I just gave up after a couple days, it was kind of a configuration hell.
ElasticSearch + Tire was a breezy to get it up and running, I got it working in an hour.
Lucene is just a Java search library, hence Solr was developed to be a full service search app, but Solr still have all the trapping of a typical Java webapp: overly complicated XML configurations, schema-heavy, expect XML docs for indexing, requires a Java servlet container (Jetty or Tomcat), which just become too many points of failure for me.
ElasticSearch is based on Lucene too, it has a built-in servlet container so just run like a daemon, use a very straight forward JSON + REST API so it's great for testing and a more natural fit for Ruby. It's schemaless and it worked for me without even editing a config file. Everything worked beautifully.
What I really needed was Chinese search and ElasticSearch already packaged Luecene's SmartChineseAnalyzer as a plugin. Not sure how difficult it will be to customize the analyzer/tokenizer chain if you need that level of customization. Docmentation for ElasticSearch and Tire are both top-notch.
Tire (Ruby library for ElasticSearch)
https://github.com/karmi/tire
You can try out the demo, it'll install a rails searchapp, download the ElasticSearch binary and run it, then start Webrick automatically.
$ rails new searchapp -m https://raw.github.com/karmi/tire/master/examples/rails-application-template.rb
On my system it complained about not having a Javascript engine (Rails 3.2? no longer include thereubyracer gem by default), so I had to:
$ wget https://raw.github.com/karmi/tire/master/examples/rails-application-template.rb
$ nano rails-application-template.rb
add gem 'therubyracer' in the file (look for gem 'tire' and gem 'will_paginate'), then...
$ rails new searchapp -m rails-application-template.rb
For developing my own app, I just downladed the ElasticSearch tarball and run in the foreground with the -f switch (so I can easily stop it by Ctrl-C)
$ bin/elasticsearch -f
You can install the eleasticsearch-head plugin to get a web admin interface
https://github.com/mobz/elasticsearch-head
Also something I found out: if you have one-to-many relationship models, Tire won't resolve them for you in the search results, it just returns a flat collection. Your has_many and belongs_to relationships will just be object ids in the collection rather than full objects.
I think you should search for a comparison between Solr and elastic search.
In fact sunspot is based on Solr, and both Solr and elastic search are based on Lucene. They are two different projects with similar goals, both built on top of Lucene.
Here are two comparisons:
ElasticSearch, Sphinx, Lucene, Solr, Xapian. Which fits for which usage?
http://www.findbestopensource.com/article-detail/solr-vs-elasticsearch
Here is the most complete up-to-date post on the topic: http://solr-vs-elasticsearch.com/
My recommendations as of May 2018
Here are some simple guidelines if the crazy long grid of features
above did not help.
Choose Solr if any of the following are true...
Your team consists mainly of Java programmers
You're already using ZooKeeper in your stack
You're already using Java in your stack
You are building a search application that has specific and nuanced relevancy requirements
You are building an ecommerce, job, or product search engine
Search is a central part of your product and user experience and there is the organizational mandate for search to be a core strength
Choose Elasticsearch if any of the following are true...
Your team consists mainly of Ruby/PHP/Python/full stack programmers (and your application does not have specific and nuanced relevancy
requirements)
You live and breathe JSON
You already use Kibana/ELK for managing your logs
Your application is analytics-heavy
If in doubt...
Every serious search application I have worked on has required
in-depth customization of the search workflow and relevancy tweaks,
and at the time of writing, this is simply not possible in
Elasticsearch without major hacking. If in doubt, go Solr.
I recently switched to MongoDB and I am wondering if I can continue using any of the popular admin interface solutions, such as ActiveScaffold and Typus?
You can try Rails Admin:
a Rails engine that provides an easy-to-use interface for managing your data.
Features
CRUD any data with ease
Custom actions
Automatic form validation
Search and filtering
Export data to CSV/JSON/XML
Authentication (via Devise or other)
Authorization (via CanCanCan or Pundit)
User action history (via PaperTrail)
Supported ORMs
ActiveRecord
Mongoid
ActiveAdmin https://github.com/gregbell/active_admin is a great tool for the admin interface creation. And I believe sooner or later they add mongoid support.
Right now there's some patch for it: https://github.com/ebeigarts/mongoid_active_admin_app
I didn't try it myself though.
if your using Mongoid as your ORM, then active_admin should do the job.. apply this patch to get it working
this disables some functionalities (mostly filters because active_admin relies on meta_search and that gem only supports active_record)
Fixes ActiveAdmin sorting
Disables ActiveAdmin Filters/Search
Disables ActiveAdmin Comments
I think you'll find this page on MongoDB's site to be the best help:
http://www.mongodb.org/display/DOCS/Admin+UIs
There are many admin applications available, some in browser, some fat client, etc. that you can use for admin and maintaining your Mongo backend.
I am a .Net programmer so I have used only MongoVUE, but one that caught my eye that I might check out and it should be platform agnostic is JMongoBrowser
I'd bet plenty options will work with a RAILS setup.
Is there a pattern or a gem (Ruby on rails) for modeling the wiki-like behaviour of a StackOverflow like web site?
I'm working on Ruby-on-Rails project so a gem or something in RoR would be appreciated but a well defined pattern is just as good.
Thanks
Did you try act_as_versioned? It is available as a gem, and adds simple versioning to any ActiveRecord model.
If you need more features, act_as_revisable might be interesting. According to the link, it adds the following features on top of act_as_versioned:
Pervasive Callbacks
Branching and Changesets
Deletes can be stored as a revision
Explicit is better than implicit
All data for a model is stored in one table
Wrapping up, requirements and installing
My current project is in Rails. Coming from a Symfony (PHP) and Django (Python) background, they both have excellent admin generators. Seems like this is missing in Rails.
For those who aren't familiar with Symfony or Django, they both allow you to specify some metadata around your models to automatically (dynamically) generate an admin interface to do the common CRUD operations. You can create an entire Intranet with only a few commands or lines of code. They have a good appearance and are extensible enough for 99% of your admin needs.
I've looked for something similar for Rails, but all of the projects either have no activity or they died long ago. Is there anything to generate an intranet/admin site for a rails app other than scaffolding?
Active Admin (http://activeadmin.info/) was released in May of 2011, and looks like it's going to become the best Rails 3 option.
rails_admin appears to be the latest-n-greatest free project as of January 2011.
...best of all, there has been a lot of activity in the repository.
Scaffolding is the normal way to create an admin backend BUT there is a project called ActiveScaffold which may solve your problem.
Here is a roundup of a few options, including more than just ActiveScaffold.
ActiveScaffold is available for Rails 2.3.x :)
Just for someonse's info who have found this question one year later like me :)
ActiveScaffold is a good solution, but if you want a more configurable and powerful tool, I think Typus is a great solution:
http://github.com/fesplugas/typus
You have mainly two:
ActiveScaffolding: the most popular but be careful with rails 2.1
Streamlined
ActiveScaffold is by far and away the most configurable/easiest to integrate/most automagic scaffolding around at the moment.
It has built in ajax support, near seamless db introspection and it even plays nicely with legacy Oracle databases (which can be a real pain in Rails).
Try it: http://activescaffold.com/
Have a look at Casein (http://www.caseincms.com/), might be what you're looking for.
Having also tried typus, caseincms and ActiveScaffold over the weekend, I can't rave enough about admin_data.
It is
super-quick to install (Rails 3 is the gem, Rails 2.3 is a plugin branch,
no digging through trees on github),
unintrusive (all code is in the vendor/admin_data folder or the gem where it belongs),
requires no set-up and optional configuration is one block in one file in your app,
correctly (!) gets all model information from your model definitions (primary_key, foreign_key, relationships etc.),
including multiple databases, SQL Server connections via activerecord-sqlserver-adapter, and even composite primary keys, as everything is abstracted on top of ActiveRecord, if you model works, admin_data will work,
works great with legacy data for the above reasons,
uses your existing authentication solution which is called in the most wonderful DRYness in your configuration file.
It maybe less flexible or pretty than other solutions, but this plugin does many thingks right for quick admin panel setup.
The most common way to create a CRUD interface is to use Scaffold.
./script/generate scaffold_resource MyModel property:type property2:type2
This command would generate a CRUD interface for the model named MyModel (singular) with two properties. Properties is what's called columns in DB lingo. So you could have name:string age:integer active:boolean etc.
I can suggest you active_admin that is best
Active Admin main site