We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Lucene - Permission Filter and numeric search

RockSC
RockSC asked
on
Medium Priority
1,514 Views
Last Modified: 2013-12-08
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

Comment
Watch Question

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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.