Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 19173 invoked from network); 3 May 2006 19:52:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 3 May 2006 19:52:34 -0000 Received: (qmail 30157 invoked by uid 500); 3 May 2006 19:52:28 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 30131 invoked by uid 500); 3 May 2006 19:52:28 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 30120 invoked by uid 99); 3 May 2006 19:52:28 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 May 2006 12:52:28 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [200.199.23.120] (HELO gonzaga.cesar.org.br) (200.199.23.120) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 May 2006 12:52:25 -0700 Received: (qmail 65591 invoked from network); 3 May 2006 19:59:28 -0000 Received: from unknown (HELO pinho) (172.27.71.173) by gonzaga.cesar.org.br with SMTP; 3 May 2006 19:59:28 -0000 Message-ID: <002401c66eec$16420340$ad471bac@intraet.cesar.org.br> From: "Rodrigo Marcuschi" To: Subject: Problem with lucene 1.9.1 Date: Wed, 3 May 2006 16:59:28 -0300 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0021_01C66ED2.F09A2820" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_NextPart_000_0021_01C66ED2.F09A2820 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello,=20 I am having problems using lucene 1.9.1. I was using 1.4.3 successfully, = and tried upgrading to 1.9.1. As I changed my source code so I would no = longer be invocating deprecated methods, the application no longer = worked properly, i.e. the IndexModifier was no longer storing documents. = Here is my source code: -------------------------------------------------------------------------= ------------------------------ package org.cesar.trulog.search.api; import java.io.File; import java.io.IOException; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.index.IndexModifier; public class UserIndexer { public static final String ID =3D "userId"; public static final String KEYWORDS =3D "searchKeywords"; public static final String USERNAME =3D "searchUsername"; private final File index; private final Analyzer analyzer; private IndexModifier modifier;=20 public UserIndexer(final Analyzer analyzer, final String dir) throws = IOException { index =3D new File(dir); =20 this.analyzer =3D analyzer; synchronized(UserIndexer.class) { if (!index.exists()) { index.mkdirs(); } } =20 this.modifier =3D new IndexModifier(this.index, this.analyzer, = true); } public UserIndexer(final String dir) throws IOException { this(new StandardAnalyzer(), dir); } =20 private Document getDocument(final SearchItem searchItem) { Document doc =3D new Document();=20 doc.add(new Field(ID, ((Integer) = searchItem.getValue(SearchItemField.ID)).toString(), Field.Store.YES, = Field.Index.UN_TOKENIZED)); doc.add(new Field(KEYWORDS, (String) = searchItem.getValue(SearchItemField.KEYWORD), Field.Store.YES, = Field.Index.TOKENIZED)); doc.add(new Field(USERNAME, (String) = searchItem.getValue(SearchItemField.NAME), Field.Store.YES, = Field.Index.TOKENIZED)); =20 return doc; } =20 public synchronized void add(final SearchItem searchItem) throws = IOException {=20 modifier.deleteDocuments(new Term(ID, ((Integer) = searchItem.getValue(SearchItemField.ID)).toString())); =20 Document doc =3D this.getDocument(searchItem); modifier.addDocument(doc); modifier.flush(); System.out.println(modifier.docCount() + " docs in index"); modifier.close(); =20 }=20 } -------------------------------------------------------------------------= ------------------------------ SearchItem is a custom class that has the data to be used by lucene. The = relevant method in there is=20 void add(final SearchItem searchItem)=20 which calls lucene's 'addDocument' method. It used to work back when I = was using Field.Keyword, Field.Text and modifier.delete --- but all = these got deprecated, so.... Here's what happens: no matter how many = documents I add, all I get is '1 docs in index'. If I DON'T close the = modifier, I get the right results 2, 3, 4 docs in index etc --- but if = the application is restarted, the docs are lost, i.e. a search that = should return 2 or 3 results returns no result at all. Any ideas where to start? What to fix? If I should go back using the = deprecated methods? I tried using FSDirectory instead of File, didn't = work. I tried not deleting the documents before adding them, it didn't = work. I tried using a custom analyzer, it didn't work. I'm running out = of ideas. Thank you very much for your attention, Rodrigo ------=_NextPart_000_0021_01C66ED2.F09A2820--