Yaxm Yaxm
2007-Apr-24 05:42 UTC
[Ferret-talk] bitmask(bitwise operation) support in Ferret
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. Does Ferret support this kind of search? or do I have to build in inverted index as mentioned at http://www.mail-archive.com/general at lucene.apache.org/msg00372.html Thanks. Yaxm -- Posted via http://www.ruby-forum.com/.
John Leach
2007-Apr-24 11:42 UTC
[Ferret-talk] bitmask(bitwise operation) support in Ferret
Hi Yaxm, 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 Yaxm wrote:> 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. > > Does Ferret support this kind of search? > > or do I have to build in inverted index as mentioned at > http://www.mail-archive.com/general at lucene.apache.org/msg00372.html > > Thanks. > Yaxm >-- http://johnleach.co.uk