# FastRI 0.2.1: faster full-text searching, multiple queries,

**URL:** <https://www.ruby-forum.com/t/fastri-0-2-1-faster-full-text-searching-multiple-queries/77010>\
**Category:** Ruby\
**Created:** [November 23, 2006, 12:03pm UTC](https://www.ruby-forum.com/t/fastri-0-2-1-faster-full-text-searching-multiple-queries/77010 "2006-11-23T12:03:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tulkas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5daacb/32.png) [@tulkas](https://www.ruby-forum.com/u/tulkas)\
**Post date:** [November 23, 2006, 12:03pm UTC](https://www.ruby-forum.com/t/fastri-0-2-1-faster-full-text-searching-multiple-queries/77010/1 "2006-11-23T12:03:32Z")

</div>

FastRI is an alternative to the ri command-line tool. It is _much_  
faster, and  
also allows you to offer RI lookup services over DRb. FastRI is smarter  
than  
ri, and can find classes anywhere in the hierarchy without specifying  
the  
“full path”. FastRI can perform full-text searching. Its RubyGems  
support is  
better than ri’s, and it knows which gem a method/class definition came  
from.

# Getting it

Additional information, tarballs… at  
[eigenclass.org](http://eigenclass.org/hiki.rb?fastri)

FastRI can be installed with RubyGems:  
gem install fastri  
(if you get an old version/a 404 error, please allow some time after the  
release until the package propagates to the RubyForge mirrors). Please  
read  
below for an important note regarding the RubyGems packages.

# User-visible changes since version 0.2.0

- fri will use a pager in full-text search mode, and also when asked to  
(-P, -T, --[no-]pager, --pager-cmd)
- multiple queries supported: fri upcase downcase
- fri -S is 100ms faster since it avoids requiring rubygems.rb
- list all classes/modules and methods with --classes and --methods, and  
both  
with --list-names (-l)

# Usage

There are two parts to FastRI:

- the server: fastri-server
- the client: fri

FastRI uses a Rinda Ring to allow servers to be discovered automatically  
without needing to indicate the DRb URIs manually. It can work across  
machines if you make sure the ring server is bound to the correct  
interface,  
and the ACL permissions are correct.

# Examples

$ fastri-server (creates the index on the first run, blocks)

## Later, (times measured with a cold cache): $ time ruby bin/fri -f plain Array#fetch

Array#fetch  
array.fetch(index) → obj  
[…]  
real 0m0.287s (real 0m0.127s with a hot cache)  
user 0m0.048s  
sys 0m0.008s

## Compare to: $ time ri -T -f plain Array#fetch

Array#fetch  
[…]  
real 0m10.136s (real ~ 1.5s with a hot cache)  
user 0m1.140s  
sys 0m0.464s

This illustrates FastRI’s ability to locate classes deep in the class  
hierarchy:

$ fri Base  
------------------------------------------------------ Multiple  
choices:

```
  ActionMailer::Base, ActionView::Base, ActionWebService::API::Base,
  ActionWebService::Base, ActionWebService::Client::Base,
  ActiveRecord::Base, MapReduce::ActiveRecord::Base,
  RSS::Maker::Base, Scruffy::Components::Base,
  Scruffy::Formatters::Base, Scruffy::Layers::Base,
  Scruffy::Renderers::Base, Scruffy::Themes::Base

```

$ fri Themes::Base  
------------------------------------------- Class:  
Scruffy::Themes::Base  
Scruffy::Themes::Base  
Author: Brasten S.

```
  Date: August 14th, 2006

```

Compare to  
$ ri Themes::Base … several seconds later …  
Nothing known about Themes::Base

# A small note about RubyGems + FastRI.

RubyGems adds a noticeable overhead to fri, making it run slower than if  
you  
installed it directly from the tarball with setup.rb.

Compare the execution time when installed with RubyGems:  
$ time fri -f plain String \> /dev/null

real 0m0.385s  
user 0m0.244s  
sys 0m0.036s

to the time fri actually takes to run, without the overhead introduced  
by  
RubyGems:  
$ time ruby bin/fri -f plain String \> /dev/null

real 0m0.088s  
user 0m0.040s  
sys 0m0.008s

If you care about those extra 300ms (and there are situations where they  
will  
matter, e.g. when using fri for method completion), get FastRI from the  
tarballs.

# License

FastRI is licensed under the same terms as Ruby. See LICENSE.

# Feedback

Bug reports, patches, comments… are appreciated.  
You can contact the author via [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid). Please add “fastri” to the  
subject in order to bypass the spam filters.

---

<div class="post-metadata">

**Author:** ![tulkas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5daacb/32.png) [@tulkas](https://www.ruby-forum.com/u/tulkas)\
**Post date:** [November 23, 2006, 4:47pm UTC](https://www.ruby-forum.com/t/fastri-0-2-1-faster-full-text-searching-multiple-queries/77010/2 "2006-11-23T16:47:18Z")

</div>

On 11/23/06, Mauricio F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> FastRI is an alternative to the ri command-line tool. It is _much_ faster, and  
> also allows you to offer RI lookup services over DRb. FastRI is smarter than  
> ri, and can find classes anywhere in the hierarchy without specifying the  
> “full path”. FastRI can perform full-text searching. Its RubyGems support is  
> better than ri’s, and it knows which gem a method/class definition came from.

Thanks, this looks nice. However,

$ fri flatten  
------------------------------------------------------ Multiple choices:

```
 Array#flatten, Set#flatten

```

$ fri A#flatten  
nil

so I need to fully spell out which one I’m interested in. Could you  
please add a simple string distance or something like that so that one  
can use shortcuts, ie fri A#flatten should choose Array#flatten since  
it is the closest one. If I don’t misremember we discussed and added  
this functionality to ri way back then.

/Robert F.

---

<div class="post-metadata">

**Author:** ![tulkas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5daacb/32.png) [@tulkas](https://www.ruby-forum.com/u/tulkas)\
**Post date:** [November 23, 2006, 5:53pm UTC](https://www.ruby-forum.com/t/fastri-0-2-1-faster-full-text-searching-multiple-queries/77010/3 "2006-11-23T17:53:27Z")

</div>

On Fri, Nov 24, 2006 at 12:46:36AM +0900, Robert F. wrote:

> $ fri flatten  
> this functionality to ri way back then.  
> I have pushed a couple patches to HEAD  
> ([eigenclass.org](http://eigenclass.org/repos/fastri/head)) that implement these search  
> methods:

- complete namespace (m)
- complete both namespace and method (f)

FastRI’s search strategy can be specified with the -O option:

```
-O, --order ORDER Specify lookup order.
                                 (default: eEnNpPxX)
                                 Uppercase: case-indep.
                                 e:exact n:nested p:partial 

```

(completion)  
x:nested and partial m:complete  
namespace  
f:complete both class and method  
a:match method name anywhere

See [225037] for an explanation of the basic search modes.

You can make fri behave like ri (regarding partial completion of the  
namespace  
name) by adding ‘m’ to the lookup order:

$ fri -Om A#flatten  
---------------------------------------------------------- Array#flatten  
array.flatten → an\_array

Moreover,

$ fri -Of A#a  
------------------------------------------------------ Multiple choices:

```
 ACL#allow_addr?, ACL#allow_socket?, Abbrev#abbrev, Array#abbrev,
 Array#assoc, Array#at, Autotest#add_sigint_handler,
 Autotest#all_good

```

However, I’m not sure about the position in the search strategy  
(currently  
eEnNpPxX) at which the ‘m’ or ‘f’ modes could be added.  
Maybe eEnNpPxXmM(fF)a ?

Anyway, even if I left the default search strategy unchanged, it could  
be  
overridden with --order (-O).

---

<div class="post-metadata">

**Author:** ![tulkas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5daacb/32.png) [@tulkas](https://www.ruby-forum.com/u/tulkas)\
**Post date:** [November 23, 2006, 6:21pm UTC](https://www.ruby-forum.com/t/fastri-0-2-1-faster-full-text-searching-multiple-queries/77010/4 "2006-11-23T18:21:31Z")

</div>

On Nov 23, 2006, at 6:03 PM, Robert F. wrote:

> Ok, great. If it could check some ENV variable for the search order  
> people could spec their own default. FASTRI\_LOOKUP\_ORDER? I don’t  
> think that would add very much to the execution time…

Wouldn’t a simple shell alias do?

---

<div class="post-metadata">

**Author:** ![tulkas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5daacb/32.png) [@tulkas](https://www.ruby-forum.com/u/tulkas)\
**Post date:** [November 23, 2006, 6:23pm UTC](https://www.ruby-forum.com/t/fastri-0-2-1-faster-full-text-searching-multiple-queries/77010/5 "2006-11-23T18:23:33Z")

</div>

On 11/23/06, Xavier N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On Nov 23, 2006, at 6:03 PM, Robert F. wrote:
> 
> > Ok, great. If it could check some ENV variable for the search order  
> > people could spec their own default. FASTRI\_LOOKUP\_ORDER? I don’t  
> > think that would add very much to the execution time…
> 
> Wouldn’t a simple shell alias do?

Yeah, that’s right. Too late in the day over here… 😉

Regards,

/RF

---

<div class="post-metadata">

**Author:** ![tulkas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5daacb/32.png) [@tulkas](https://www.ruby-forum.com/u/tulkas)\
**Post date:** [November 23, 2006, 6:05pm UTC](https://www.ruby-forum.com/t/fastri-0-2-1-faster-full-text-searching-multiple-queries/77010/6 "2006-11-23T18:05:30Z")

</div>

> ```
> e:exact n:nested p:partial (completion)
> 
> ```
> 
> ---------------------------------------------------------- Array#flatten
> 
> However, I’m not sure about the position in the search strategy (currently  
> eEnNpPxX) at which the ‘m’ or ‘f’ modes could be added.  
> Maybe eEnNpPxXmM(fF)a ?
> 
> Anyway, even if I left the default search strategy unchanged, it could be  
> overridden with --order (-O).

Ok, great. If it could check some ENV variable for the search order  
people could spec their own default. FASTRI\_LOOKUP\_ORDER? I don’t  
think that would add very much to the execution time…

Regards,

Robert
