Víťa Plšek
2009-Jul-15 08:16 UTC
[Xapian-discuss] Filtering documents by permissions in PHP
Hello all I have small problems with filtering document by permissions in PHP. I have learn that best way is to use MatchDeciders, but I realised that there arent directors for PHP in SWIG so I cant subclass it and define my own accept method which would solve my problem. I have installed Xapian version 1.1.1 from SVN because there is wrapped XapianValueSetMatchDecider which allows me to filter document's value by given array of values. But in this case I have to prepare all ids which should or shouldn't be showed in result before search and it could take a long time and dramatically increase search latency. Is somehow possible to subclass Deciders or overide theirs accept method or define some callback in PHP? Has someone solved this problem? Or how do you filter documents by permissions? I will appreciate all you advices or comments. Thank you very much. Winsik
Olly Betts
2009-Jul-15 12:42 UTC
[Xapian-discuss] Filtering documents by permissions in PHP
On Wed, Jul 15, 2009 at 10:16:27AM +0200, V??a Pl?ek wrote:> Is somehow possible to subclass Deciders or overide theirs accept method > or define some callback in PHP?Not currently. I'm mentoring a student in Google's Summer of Code to add the needed support to SWIG to allow such subclassing, and given his progress so far it seems very likely he'll succeed. So this will probably be possible in the development version of Xapian in a month or two.> Has someone solved this problem? Or how do you filter documents by > permissions?I'd index the permissions as terms and then filter on them by building a boolean query from those terms. Then you can use OP_FILTER to combine that with the rest of your query, For example, you could model the standard Unix permissions system by indexing these terms for each document: * XUSERfoo for a file owned by user "foo" and user-readable. * XGROUPbar for a file with group "bar" and group-readable. * XWORLD for a world readable file. And if I'm in groups users and bar I can read files which match this query: XUSERolly OR XGROUPusers OR XGROUPbar OR XWORLD Cheers, Olly