On May 12, 2010, at 7:42 PM, roy-lucene-u...@xemaps.com wrote: > Hi guys, > > I've had this code for some time but am just now questioning if it works. > > I have a custom filter that i've been using since Lucene 1.4 to Lucene 2.2.0 > and it essentially builds up a BitSet like so: > > for ( int x = 0; x < fields.length; x++ ) { > for ( int y = 0; y < values.length; y++ ) { > TermDocs termDocs = reader.termDocs( new Term( fields[x], values[y] ) ); > try { > while ( termDocs.next() ) { > int doc = termDocs.doc(); > bits.set( doc ); > } > } > finally { > termDocs.close(); > } > } > } > > I notice that it grabs all the TermDocs for the first field and value but > nothing after that. But I do know that the other values exist but I don't > get any TermDocs afterwards. >
That code works for me against Lucene 3.0.1 (and I don't think much has changed there). Are you sure the fields and values are lining up right? Perhaps isolate this on a standalone index to convince yourself. Have you looked at Luke to validate? However, why not just create a Filter from a Query and get the bitset/docidset using the MultiFieldQueryParser? //Here's a snippet I wrote, never mind the PayloadAnalyzer, just substitute in your analyzer MultiFieldQueryParser mfqp = new MultiFieldQueryParser(Version.LUCENE_30, fields, new PayloadAnalyzer(encoder)); Query query = mfqp.parse(Version.LUCENE_30, values, fields, new PayloadAnalyzer(encoder)); Filter filter = new QueryWrapperFilter(query); DocIdSet docs = filter.getDocIdSet(reader); DocIdSetIterator docIdSetIterator = docs.iterator(); while (docIdSetIterator.nextDoc() != DocIdSetIterator.NO_MORE_DOCS){ System.out.println("Doc: " + docIdSetIterator.docID()); } -------------------------- Grant Ingersoll http://www.lucidimagination.com/ Search the Lucene ecosystem using Solr/Lucene: http://www.lucidimagination.com/search --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org