Hi,
in my person model,
I have a enumeration field “role” that take bits like 1, 2, 4, 8, 16,
…
they represent person roles(eg: admin(1), QA(2), manager(4) … ).
Each person can take on multiple roles.
say there’s person A that’s both a admin and QA(the role value is “3”)
so if I search like “Person.find_by_content('role:(1))”, I expect it to
return person A. but this clearlly doesn’t work.
I’m not sure about bitwise search operations, but you can index the
return value of methods, as well as ActiveRecord attributes.
You could write a method called “role_text” that returns a string
according to the value of role: “admin manager”, and index that. Then
you can search: ‘role_text:admin’ and get all the admins.
Just make sure that the strings you use don’t get tokenized ambiguously
(this depends on your analyzer I guess).
Hope this is useful.
John.
On Tue, 2007-04-24 at 07:42 +0200, Yaxm Y. wrote:
so if I search like “Person.find_by_content('role:(1))”, I expect it to
return person A. but this clearlly doesn’t work.