Return-Path: Delivered-To: apmail-jakarta-lucene-dev-archive@apache.org Received: (qmail 45603 invoked from network); 21 May 2002 12:03:44 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 21 May 2002 12:03:44 -0000 Received: (qmail 5420 invoked by uid 97); 21 May 2002 12:03:41 -0000 Delivered-To: qmlist-jakarta-archive-lucene-dev@jakarta.apache.org Received: (qmail 5381 invoked by uid 97); 21 May 2002 12:03:41 -0000 Mailing-List: contact lucene-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Lucene Developers List" Reply-To: "Lucene Developers List" Delivered-To: mailing list lucene-dev@jakarta.apache.org Received: (qmail 5369 invoked by uid 98); 21 May 2002 12:03:40 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) Message-ID: <001901c200bf$880c82b0$9865fea9@hurrican> From: "Christian Meunier" To: Subject: Re: Filter abstract class / Why there is no getter method for the field "Field" ? Date: Tue, 21 May 2002 14:03:33 +0200 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0016_01C200D0.4B137880" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N ------=_NextPart_000_0016_01C200D0.4B137880 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I'm not sure if my last email has dropped through the cracks, so I'm=20 reposting it just in case it has. Thanks for your insights in advance, Chris ----- Original Message -----=20 From: Christian Meunier=20 To: lucene-dev@jakarta.apache.org=20 Sent: Wednesday, May 15, 2002 7:32 PM Subject: Filter abstract class / Why there is no getter method for the = field "Field" ? Hi all, i am using lucene since few months and i dont understand why the = abstract class does not provide a getter method like abstract public String getField(); To my knowledge, a filter is always applied to a field ( DateFilter = has a field "Field" ). In my application , i defined a simple FilterField class: FieldFilter.java = -------------------------------------------------------------------------= -------------------------------------------------------------------------= ---------------- import java.util.BitSet; import java.io.IOException; import org.apache.lucene.index.Term; import org.apache.lucene.index.TermDocs; import org.apache.lucene.index.IndexReader; public class FieldFilter extends org.apache.lucene.search.Filter { =20 private String field; private String value; private Term searchTerm; =20 public FieldFilter(String field, String value) { this.field =3D field; this.value =3D value; searchTerm =3D new Term(field, value); } =20 public String getField() { return field; } =20 public BitSet bits(IndexReader reader) throws IOException { BitSet bits =3D new BitSet(reader.maxDoc()); TermDocs matchingDocs =3D reader.termDocs(searchTerm); try { while(matchingDocs.next()) { bits.set(matchingDocs.doc()); } } catch (Exception e) { /* ignore */ } finally { if (matchingDocs !=3D null) { matchingDocs.close(); } } return bits; } } = -------------------------------------------------------------------------= -------------------------------------------------------------------------= ---------------- I then coded a class which handle multiple filters (FieldFilter, = DateFilter,....) at once MultiFilter.java = -------------------------------------------------------------------------= -------------------------------------------------------------------------= ---------------- import java.util.Hashtable; import java.util.BitSet; import java.util.ArrayList; import java.io.IOException; import org.apache.lucene.index.Term; import org.apache.lucene.index.TermDocs; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.Filter; public class MultiFilter extends org.apache.lucene.search.Filter { private ArrayList filterList; public MultiFilter() { filterList =3D new ArrayList(); } public MultiFilter(int initialCapacity) { filterList =3D new ArrayList(initialCapacity); } =20 public String getField() { return null; } public void add(Filter filter) { filterList.add(filter); } public BitSet bits(IndexReader reader) throws IOException { int filterListSize =3D filterList.size(); =20 if (filterListSize > 0) { Hashtable filters =3D new Hashtable(); int pos=3D0; for (int i=3D0; i