# Advice on Search Design

**URL:** <https://www.ruby-forum.com/t/advice-on-search-design/186121>\
**Category:** Rails\
**Created:** [March 31, 2010, 8:42pm UTC](https://www.ruby-forum.com/t/advice-on-search-design/186121 "2010-03-31T20:42:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [March 31, 2010, 8:42pm UTC](https://www.ruby-forum.com/t/advice-on-search-design/186121/1 "2010-03-31T20:42:31Z")

</div>

I’ve been having problems submitting a question to this forum so sorry  
in advance if this is a repeat.

I am not looking for code examples, just a pointer in the right  
direction as far as design. I am trying to do a search based on  
information form 4 select boxes. None of the select boxes are mandatory  
so there could be a lot of possible combinations.

search for field one, field one and two, field two and three, etc.

I know an if else statement for all the possible combinations would not  
be the right way to go. Should I use Ferret or Sphinx to do a search  
like this or is there a better way.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [March 31, 2010, 9:22pm UTC](https://www.ruby-forum.com/t/advice-on-search-design/186121/2 "2010-03-31T21:22:29Z")

</div>

Google for “searchlogic”. It’s a rails plugin that makes stuff like  
this  
very easy to do.

Jamey

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [March 31, 2010, 9:38pm UTC](https://www.ruby-forum.com/t/advice-on-search-design/186121/3 "2010-03-31T21:38:08Z")

</div>

I researched searchlogic prior to posting and unless I am missing  
something I don’t see how it would get around something like this:

if a,b & c but not d  
…  
elsif a & b but not c & d  
…  
elsif a and not b,c & d

I did see something construct a mysql query, based on something like:

query = “”  
if a then query \<\< “”  
if b then query \<\< “”  
if c then query \<\< “”  
if d then query \<\< “”

but they also stated this was a bad idea…

Am I missing something within the searchlogic doc?
