Compound search / grouping

Hi,

Following problem:

We have a tree structure with children and a root element (recursivly)
stored in one table (imagine a threaded forum).

Each of the children has a title which should be indexed by ferret.

Now we want to make a search that returns only the root and searches all
items.

So if one node has “expensive” and nother node has “car” I want to enter
“expensive car” in search and still find the root of all children (and
only once!)

Also paging should work as well.

Any clues how to achieve that?

Regards
Till

On Tue, Nov 20, 2007 at 01:17:30PM +0100, Till V. wrote:

items.

So if one node has “expensive” and nother node has “car” I want to enter
“expensive car” in search and still find the root of all children (and
only once!)

Also paging should work as well.

Any clues how to achieve that?

An instance method in the root class to the effect of
children_titles_with_spaces would get you this. That method would
return
“expensive car” given your simple, two-node example, which would be
indexable with the normal analyzer.

-Chris

Hi,
Thank you for the clue.
Ok, like a virtual attribute. Works technically but:
Downside: How often is that called ? Our tree has e.g. 200 children.
This means that the children are collected on every change of one of
the children (index) or?
Any other ideas?
Regards
Till

Am 20.11.2007 um 13:52 schrieb Chris S.:

-Chris


Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Codemart GmbH
Till V.
Managing Director
Tel: +49 (0)89 1213 5359
Mob: + 49 (0)160 718 7403
Fax: +49 (0)89 1892 1347
Yahoo ID: till_vollmer
Skype: till_vollmer
www.codemart.de
[email protected]

Hi,
Thank you for your answer.

The root and the nodes are in the same table for us.
Is there no “group_by” or something for ferret? That would probably
make the deal.

Regards
Till

Am 20.11.2007 um 14:36 schrieb Chris S.:

child
-Chris

Regards

We have a tree structure with children and a root element
So if one node has “expensive” and nother node has “car” I want
children_titles_with_spaces would get you this. That method would
Codemart GmbH

[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Codemart GmbH
Till V.
Managing Director
Tel: +49 (0)89 1213 5359
Mob: + 49 (0)160 718 7403
Fax: +49 (0)89 1892 1347
Yahoo ID: till_vollmer
Skype: till_vollmer
www.codemart.de
[email protected]

If it’s all the same class, then don’t index children:

def ferret_enabled?(is_rebuild = false)
@ferret_disabled.nil? && self.root?
end

Only root nodes would get indexed with the above method (and an
appropriate root? definition) in place.

AFAIK, there is no group_by concept in aaf. At the same time, I don’t
think it’s really necessary. The above, combined with a single method
definition for children_titles_with_spaces should get you exactly what
you’re looking to do.

-Chris

On Tue, Nov 20, 2007 at 03:08:52PM +0100, Till V. wrote:

Am 20.11.2007 um 14:36 schrieb Chris S.:

updates into a queue that performs bulk updates. This would minimize the

Thank you for the clue.

Now we want to make a search that returns only the root and searches

Ferret-talk mailing list
Skype: till_vollmer
[email protected]
Mob: + 49 (0)160 718 7403
Fax: +49 (0)89 1892 1347
Yahoo ID: till_vollmer
Skype: till_vollmer
www.codemart.de
[email protected]

If you are using acts_as_ferret, it will never get called. The
acts_as_ferret declaration would go on the root class. Updates to the
child classes would not trigger an aaf index update in the root class.

If you want to real-time index updates, you would have to add an
after_save callback to the child class that forces an aaf update in the
root class.

If real-time updates are not too important, then you could dump the
child
updates into a queue that performs bulk updates. This would minimize
the
number of times this method gets called.

If you’re worried about 200+ SQL calls, don’t perform the join in ruby,
do
it via SQL using CONCAT and “Advanced Attribute” as described in AWDWR,
19.3.

-Chris

On Tue, Nov 20, 2007 at 02:01:39PM +0100, Till V. wrote:

Each of the children has a title which should be indexed by ferret.

[email protected]
www.codemart.de
[email protected]