Gitorious: Enable wildcard search

Since we started using Gitorious, I wondered why its search results were so bad. Searching for foo did not return repository aida_footnotes. Not even searching for footnotes returned that repository. Searching for *foo* did not work either.

Underscore as word separator

The reason for this behavior is that _ is seen as character that is part of a word, defined in the charset_table setting.

You may now either modify the charset_table setting by removing the underscore, or by simply adding _ to the ignore_chars setting.

With that setting, words are split by underscores, too. Searching for foo finds a repository named some_foo_bar once you've re-built the search index:

$ env RAILS_ENV=production bundle exec rake ts:rebuild

Wildcard search

While splitting words by underscore helped to some great extend, it did still not allow wildcard searches for *foo*.

To enable that feature, add the following settings to your config/sphinx.yml:

enable_star: 1
min_infix_len: 2

enable_star makes the asterisk work while min_infix_len shortens the minimal search word length to 2, so that a search for *fo* works.

After that, rebuild the thinking sphinx search index:

$ env RAILS_ENV=production bundle exec rake ts:rebuild

Written by Christian Weiske.

Comments? Please send an e-mail.