dougal / acts_as_indexed

Acts As Indexed is a plugin which provides a pain-free way to add fulltext search to your Ruby on Rails app
http://douglasfshearer.com/blog/rails-plugin-acts_as_indexed
MIT License
211 stars 49 forks source link

Fix for multiple negative words queries #35

Closed phurni closed 12 years ago

phurni commented 12 years ago

When querying with multiple negative words, I think that the expected behaviour is to match documents without any of them, not all of them.

Example: dog -cat -bird should match all documents with dog but without cator bird

Currently it matches all documents with dog without catAND bird

dougal commented 12 years ago

So if we have four documents:

Then the search: cat -dog -bird Should return documents 2, 3 and 4?

phurni commented 12 years ago

@dougal No, my understanding of this query is: documents with cat but without dog or without bird. So it should yiled only document 4.

phurni commented 12 years ago

Ok, since the semantics of those kind of queries are open to interpretations, I took a different approach. I refactored the SearchIndex to be able to default to OR between query terms.

Forget about this PR, I'll send a new one with the new code which will not break existing queries.