# Negation for searches

**URL:** <https://www.ruby-forum.com/t/negation-for-searches/190620>\
**Category:** Rails\
**Created:** [June 23, 2010, 11:39pm UTC](https://www.ruby-forum.com/t/negation-for-searches/190620 "2010-06-23T23:39:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thitsa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5daacb/32.png) [@thitsa](https://www.ruby-forum.com/u/thitsa)\
**Post date:** [June 23, 2010, 11:39pm UTC](https://www.ruby-forum.com/t/negation-for-searches/190620/1 "2010-06-23T23:39:57Z")

</div>

What is an efficient way to search for records that does not contain a  
specific keyword.

e.g.

Find people where the state is not “MA” and first name contains “John”.

This should find:

John D. in NY  
Johnston Ried in CA

But not:

John Swann in MA

I have been using my own search routines for this but they are not very  
efficient. I’d like to upgrade it to something like  
acts\_as\_fulltextable, Ferret, or Solr, but not sure which one is  
suitable for what I need.

Thanks!

---

<div class="post-metadata">

**Author:** ![thitsa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5daacb/32.png) [@thitsa](https://www.ruby-forum.com/u/thitsa)\
**Post date:** [June 23, 2010, 11:43pm UTC](https://www.ruby-forum.com/t/negation-for-searches/190620/2 "2010-06-23T23:43:02Z")

</div>

use sphinx with gem as thinking\_sphinx  
is super fast full text search engine  
Best Regards, Dieinzige

On 23 Jun, 2010,at 09:39 PM, Thitsa M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

What is an efficient way to search for records that does not contain a  
specific keyword.

e.g

Find people where the state is not “MA” and first name contains “John”.

This should find:

John D. in NY  
Johnston Ried in CA

But not:

John Swann in MA

I have been using my own search routines for this but they are not very  
efficient. I’d like to upgrade it to something like  
acts\_as\_fulltextable, Ferret, or Solr, but not sure which one is  
suitable for what I need.

## Thanks!

Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

–  
You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).
