All threads / Search Filters/Report Generator

Ask A Question


You’re not receiving notifications from this thread.

Search Filters/Report Generator

RJ McCollam asked in Rails

I am working on a project for a client that consists of a primary jobs model that has a number of forms (other models) within it.

I am needing to build out search functionality that searches through all models in order to return a job that matches. This search also needs to include filters with the ability to filter by client, time frame, and a couple other pieces of data.

In looking through possible solutions i think that the most recent video Chris did on elasticsearch with filters ( might be what I am after.

What I havent seen in the research I have done so far is searching through multiple models. Would elasticsearch with filters be a good option to accomplish what I am trying to?

hmm, try ransack.

I'm using it , it's great if you don't want to go to the expensive of setting up a elastic search server.

You can search multiple models at once with Searchkick by doing the following: "milk", index_name: [Product, Category]

And you can also customize the search_data method on the model to include attributes from associated models.

This example builds up a string to index of all the tags stored in an association on the record.

  def search_data
      name_tagged: "#{name} #{" ")}"

Thanks Joe and Chris for both of your feedback. I decided to go with ElasticSearch and Searchkick since there seems to be more current documentation for what I am trying to accomplish.

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 53,130+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2021 GoRails, LLC. All rights reserved.