Git Product home page Git Product logo

Comments (7)

mrkamel avatar mrkamel commented on June 6, 2024

I don't fully understand. You use multiple db's? If yes, how do you want search cop to work in this scenario?

from search_cop.

westonganger avatar westonganger commented on June 6, 2024

Well hopefully join using the database/table that the associated model uses. Is this doable with this or have I surpassed the scope of this gem.

from search_cop.

mrkamel avatar mrkamel commented on June 6, 2024

I still don't fully understand what you try to achive. Can you provide more details? Schema, Model, what lives in which db? Thanks

from search_cop.

westonganger avatar westonganger commented on June 6, 2024
class SharedModels < ActiveRecord::Base
  self.abstract_class = true
  establish_connection "master_#{Rails.env}"
end         

class Site < SharedModels
  has_many :nodes
end

class Node < ActiveRecord::Base
  belongs_to :site

  search_scope :search do 
    attributes :name, :description, site: ["site.site_code", "site.name"]
  end
end

Node is in application database, Site is in master database. Im performing the search on node.

from search_cop.

mrkamel avatar mrkamel commented on June 6, 2024

Ah, ok, thanks. However, cross db join's are not possible SQL wise. As SearchCop operates on the SQL level, this won't work, sorry.

from search_cop.

westonganger avatar westonganger commented on June 6, 2024

great thanks for your help, any tips on implementing this?

from search_cop.

mrkamel avatar mrkamel commented on June 6, 2024

Search both models individually

@nodes = Node.search(params[:q_nodes])
@sites = Site.search(params[:q_sites])...

and "merge" the results application wise or add a single data source and index/denormalize your data there to search for both at the same time (ElasticSearch, Solr, Sphinx).

from search_cop.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.