Giter Club home page Giter Club logo

Comments (2)

brocktimus avatar brocktimus commented on August 16, 2024

Yeah this is more of a general querying thing than a scoped_search thing ;-). I've done similar before, you can't do it directly in the gem because you can't do it directly in SQL. (NOTE: you can-ish but its super vendor specific)

So does the search just need to match any children within the tree starting from the parent? What I do in that case is I get out all the relevant node_ids first and then run a query like:

class Node < ActiveRecord::Base

  scoped_search on: :name

  def recursive_children
    children_ids = # some logic to find recursive child ids
    Node.where(id: ids)
  end
end

parent.recursive_children.search_for('foo')

Basically you make a method first that returns an AR::Relation, and then you can search that. That will work to return any node with a matching string within the tree. It won't match the case if the search needs to be applied to every level and all return true.

from scoped_search.

voodoo avatar voodoo commented on August 16, 2024

Thank you very much for taking the time to look into this. That's an interesting idea. I'll give it a whirl! Thanks again

from scoped_search.

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.