lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ian Vink" <ianv...@gmail.com>
Subject Re: Design guidance - search strategy
Date Fri, 05 Dec 2008 02:48:45 GMT
It works.
For those using Lucene.NET here is an example of a Filter that takes a list
of IDs for books:


    public class BookFilter: Filter
    {
        private readonly List<int> bookIDs;

        public BookFilter(List<int> bookIDsToSearch)
        {
            bookIDs = bookIDsToSearch;
        }

        public override BitArray Bits(IndexReader reader)
        {
            BitArray bits = new BitArray(50000);
            int[] docs = new int[1];
            int[] freqs = new int[1];

            foreach (int bookID in bookIDs)
            {
                TermDocs termDocs = reader.TermDocs(new Term("id",
bookID.ToString()));
                int count = termDocs.Read(docs, freqs);
                if(count==1)
                    bits.Set(docs[0],true);
            }
            return bits;
        }
    }

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message