# Inverted index?

**URL:** <https://www.ruby-forum.com/t/inverted-index/161667>\
**Category:** Ferret\
**Created:** [February 28, 2009, 6:37pm UTC](https://www.ruby-forum.com/t/inverted-index/161667 "2009-02-28T18:37:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![helix\_tp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ed655f/32.png) [@helix\_tp](https://www.ruby-forum.com/u/helix_tp)\
**Post date:** [February 28, 2009, 6:37pm UTC](https://www.ruby-forum.com/t/inverted-index/161667/1 "2009-02-28T18:37:07Z")

</div>

Wondering if this is an appropriate application of ferret…

I need to be able to do a substring search; e.g. a search on ‘fred’  
would match ‘alfred’, ‘freddo’, ‘frederick’, etc…

The field in question is short (yes, it’s a username), but doing a MySQL  
“LIKE ‘%fred%’” seemms to be unacceptably slow.

I’m thinking if I put together a quick trailing-substring analyzer, this  
would be pretty easy to do with ferret. E.g., ‘alfred’ gets indexed as:  
alfred  
lfred  
fred  
red

(3-char word minimum is probably ok in this case)

Thoughts? Is there a better way to do this?

Thanks… dwh
