[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1447
  • Last Modified:

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

0
RockSC
Asked:
RockSC
1 Solution
 
RockSCAuthor Commented:
I think that is working now..
changed from this:
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));            
 
 
to:
doc.add(new Field("docAccessGroups", docAccessGroups, Field.Store.YES, Field.Index.ANALYZED));
doc.add(new Field("DIRAccessGroups", dirAccessGroups, Field.Store.YES, Field.Index.ANALYZED));
doc.add(new Field("channelAccessGroups", channelAccessGroups, Field.Store.YES, Field.Index.ANALYZED));            

Open in new window

0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now