Searching in a Tree-Navigation

Hello Everyone,

i am currently researching with what way i can best develop a tree-hierarchy with a search function.

So what i got: I got a hierarchical database with 13.000 datafields. Currently i ordered it like the following:

Every ITEM has an ID, and a PRE_ID (only the ROOT which has the ID 0 has no PRE_ID).

So now there are different levels. For instance all ITEMS on level 1 reference to the root with PRE_ID = 0.

Every ITEM on level 2 references an item on level 1 etc.etc..

If you think about it, at the end you got a tree starting with a root.

Now what i would like to do would be to represent this TREE as some kind of Tree-Navigation. Meaning - a multi level Tree- navigation (something like this):

Ok - now the bigger Problem. Since i got 13.000 Knots - i want to be able to search in the navigation.

Every knot has a description. So i want to add a field and if I for instance enter the term "blue" the tree should change based on the search term.

So, the way i want to change the tree is that a term is found, the tree should open the specific branch everywhere where the term can be found.

I guess creating the navigation might work with the given jquery-pluin. The big problem i see is combining it with a search and a way how to display the results.

At the moment i am not stuck with anything - i can even change the way i handle the data (the IDs). Just the reference structure need to be somehow conserved. Does anyone have any suggestions? I mean i guess i could program it by myself (tons of work) - but i really would prefere an easier solution - meaning an already created plugin or similar stuff.

So far - could not find anything in the internet.

Aprreciate any help!


Have you checked out ancestry?

Take a look at GitHub - collectiveidea/awesome_nested_set: An awesome replacement for acts_as_nested_set and better_nested_set.

It is a robust gem that would make traversing your nested tree structure a bit easier.