How do I pass a list of 'allowed' IDs to filter a Lucene search?

我只是一个虾纸丫 提交于 2019-12-24 01:54:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!