You are here: Forums Ask a Rails expert Advanced searching...
Posted in Forums : Ask a Rails expert
Authority 0
Posting Rating 69
Sign in to rate this post
|
Hi, I’d like to build a search function on my website that searches multiple tables in my database. So the pages table looks like and the pages_categories looks like At the moment, I can search in the pages table in it’s title or content. A page can also be a parent (for example fruit), if it’s a parent the parent_id is empty.
So I’d like to search in the page_categories, in the pages and in the children of a page. Some examples, How can I do this on a rails way? |
Authority 87
Posting Rating 2
Sign in to rate this post
|
hi m rails developer. 15 days free trial, Web 2.0 web application using Ruby on Rails,Talentd ruby on rails professionals,cost effective development,Ruby on rails developer,Agile development processes, save almost 60% of your development cost,Open source and completely free application framework. http://www.railsteam.com |
Authority 25
Posting Rating 29
Sign in to rate this post
|
Hi, I think this is the query you needed.. Page.all(:conditions=>[‘nl_title like ? || nl_content like ? || nl_intro like ?’, ‘fruit’, ‘fruit’, ‘fruit’]) If u want to search from 2 tables related each other, see my blog.. http://srikanthjeeva.blogspot.com/2010/01/include-in-rails-query.html Thanks, |
Authority 0
Posting Rating 69
Sign in to rate this post
|
Thanks Srikanth, that works like a charm:) |
|
Authority 50
Posting Rating 55
Sign in to rate this post
|
If your site is going to have a lot of content and search is going to be prominent, you may want to consider adding a search engine such as SOLR or Sphinx. I’ve used SOLR with Lucene in a previous project. Setting up and configuring the server is pretty straight forward. Search results are very fast, especially if you use the results from the search engine directly and not look up every result in your database. |
Authority 50
Posting Rating 0
Sign in to rate this post
|
I too would recommend using a plugin if you want to easily search across multiple models. Thinking Sphinx is great if you have a large database, but needs some extra work to re-index the data periodically. For smaller projects, searchlogic is a good option since it’s really easy to get started with. |
Authority 87
Posting Rating 2
Sign in to rate this post
|
ya , ur idea is gud for starting base. |
Authority 25
Posting Rating 0
Sign in to rate this post
|
If you want query based searching then go for searchlogic and if you want full text search then go for acts_as_ferret. It is better than Sphnix. In older version of rails sphnix break the server. |
Authority 0
Posting Rating 0
Sign in to rate this post
|
I am testing your idea.. Prathap Rajamani |
|
Authority 62
Posting Rating 69
Sign in to rate this post
|
sphinx and solr are both very robust indexed search options. i perfer acts_as_solr over acts_as_ferret for solr. thinking sphinx is an excellent gem for sphinx. i would give solr the nod simply due to the fact heroku doesn’t support sphinx and heroku rocks. solr does give you actual document indexing which may or may not come in handy. other than that i would say there are rather equal. |
Ask a Rails expert : nested application ApplicationController get called intead of children::ApplicationController
Ask a Rails expert : Best way to structure a database for a large/static dataset
Ask a Rails expert : Ruby Developer (ROR) - Scottish based (Remote working from within the UK)
Ask a Rails expert : Above Ground Pool Supplies
Ask a Rails expert : How to get url params in observer or model in Rails 3.1
Ask a Rails expert : What can persuade you to hire Junior Ruby devs with significant PHP experience?
Ask a Rails expert : What industry value does the Ruby or Rails Certification currently have?
Ask a Rails expert : Louis Vuitton Damier Azur Canvas specially sale ( www.salecheaplouisvuitton.com )
Ask a Rails expert : ·How to check errors/puts statements from ruby files which are under cronob
Ask a Rails expert : Louis Vuitton cheap Soft Sided Luggagespecial offer( www.salecheaplouisvuitton.com )