Link to home
Start Free TrialLog in
Avatar of RockSC
RockSC

asked on

Lucene - Permission Filter and numeric search

Hi,

I´m using apache lucene 2.4 and I´m trying to create a filter for public docs, but I dont know how to do this in my app.

I´m indexing docs. Each doc have one or more access groups and one DIR. Each DIR have one or more access groups. Each DIR is in one or more channels. Each channel have one or more access groups. Look the code.

The access groups are numbers and I´m indexing them separated by white spaces.

A public doc has one docAccessGroup = 0, DIR with one dirAccessGroup = 0 and Channel with one channelAccessGroup = 0

I tried this numerical search http://wiki.apache.org/jakarta-lucene/SearchNumericalFields but it didnt work.

Another approach ?

Thanks in advance.
Index:
Document doc = new Document();
doc.add(new Field("id", id, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
doc.add(new Field("title", title , Field.Store.YES, Field.Index.ANALYZED));
doc.add(new Field("docAccessGroups", docAccessGroups, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
doc.add(new Field("DIRAccessGroups", dirAccessGroups, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
doc.add(new Field("channelAccessGroups", channelAccessGroups, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));            
doc.add(new Field("doc", doc, Field.Store.NO, Field.Index.ANALYZED));
 
 
 
Search:
Permission Filter :
 
TermsFilter tf = new TermsFilter();
// try the http://wiki.apache.org/jakarta-lucene/SearchNumericalFields numerical search
tf.addTerm(new Term("docAccessGroups", "00000"));
tf.addTerm(new Term("DIRAccessGroups", "00000"));
tf.addTerm(new Term("channelAccessGroups", "00000"));
CachingWrapperFilter cachingFilter = new CachingWrapperFilter(tf);
 
// use cachingFilter to filter a query
// dont work

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of RockSC
RockSC

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial