问题
I need to return just the documents that a user has access to from a Lucene search. I can get a list of IDs from a database that make up the 'allowed' subset. How can I pass these to Lucene? The articles I've found on the web suggest I need to use a BitSet and FieldCache (am I right?), but I'm having trouble finding good examples. Does anyone have any?
I'm using C#, but any language would be great. Thanks.
回答1:
A simple way would be to build a MultiPhraseQuery with an array of all the matching IDs, via MultiPhraseQuery.add(Term[] terms)
. You can build one of these things with thousands of terms, and Lucene (as always) performs extremely well.
回答2:
Once I knew I needed to use a custom filter, asking this question got the right answer.
来源:https://stackoverflow.com/questions/795532/how-do-i-pass-a-list-of-allowed-ids-to-filter-a-lucene-search