Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 63735 invoked from network); 5 Mar 2009 15:18:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Mar 2009 15:18:13 -0000 Received: (qmail 33489 invoked by uid 500); 5 Mar 2009 15:18:07 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 33358 invoked by uid 500); 5 Mar 2009 15:18:06 -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 33346 invoked by uid 99); 5 Mar 2009 15:18:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Mar 2009 07:18:06 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of a85533109@gmail.com designates 209.85.217.170 as permitted sender) Received: from [209.85.217.170] (HELO mail-gx0-f170.google.com) (209.85.217.170) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Mar 2009 15:17:57 +0000 Received: by gxk18 with SMTP id 18so7498102gxk.5 for ; Thu, 05 Mar 2009 07:17:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type:content-transfer-encoding; bh=EHw/3IkCVmi3OI39H+S79T4LgyJ2YxW3BTiak2EtN5Q=; b=gcZ6NGVvEzLXtLVCoHHuOk9dw9WSkqDg+c2BZagllhwd/vNkAG5NyCCQZWZrqD59Bf jz7baCCTmYI8y0h3DxtzuQnGYxXFlz9VGRJlNrbQIsjCOxgOob2z65gQZ5c3CybtN95/ SzLaBBQLGb/gyleEVhaN8tIUAWtDKyeV+qbko= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=Sohx7SXYH7EcQCvy9rYuLOVTQ/8mimzZWNYEPatdkETstiVyCMMA+pHFS/hyLkL5Q4 3lc8r+Qd0H31B0AVHHvkZkvIxSiTbuW8eA44xefcqRcG2Y6hzNhykW4PWied4TCeAb6W nBvdHEw7fWEK7p2yqsab9PJlxwkEMjoQy67Ss= MIME-Version: 1.0 Received: by 10.150.199.16 with SMTP id w16mr2386212ybf.212.1236266257154; Thu, 05 Mar 2009 07:17:37 -0800 (PST) Date: Thu, 5 Mar 2009 16:17:37 +0100 Message-ID: <324177540903050717x597318dfs69669c536526c8e8@mail.gmail.com> Subject: indexing but not tokenizing From: John Marks To: java-user@lucene.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Hi all, I'm not able to see what's wrong in the following sample code. I'm indexing a document with 5 fields, using five different indexing strate= gies. I'm fine the the results for 4 of them, but field B is causing me some trouble in understanding what's going on. The value of field B is X (uppercase). The analyzer is a SimpleAnalyzer, which I use on the QueryParser as well. But when I search for X (uppercase) on field B, the X is converted to lower= case. Now, I know that SimpleAnalyzer converts to lowercase, but I was expecting it not to do so on field B, which is NOT_ANALYZED. How should I fix my code? Thank you in advance! -John --- code --- package test; import org.apache.lucene.analysis.SimpleAnalyzer; import org.apache.lucene.store.RAMDirectory; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; import org.apache.lucene.search.TopDocCollector; import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.queryParser.QueryParser; public class Test { =A0 public static void main(String[] args) =A0 { =A0=A0=A0 try =A0=A0=A0 { =A0=A0=A0=A0=A0 RAMDirectory idx =3D new RAMDirectory(); =A0=A0=A0=A0=A0 SimpleAnalyzer analyzer =3D new SimpleAnalyzer(); =A0=A0=A0=A0=A0 IndexWriter writer =3D new IndexWriter(idx, analyzer, true, =A0=A0=A0=A0=A0=A0=A0=A0=A0 IndexWriter.MaxFieldLength.LIMITED); =A0=A0=A0=A0=A0 Document doc =3D new Document(); =A0=A0=A0=A0=A0 doc.add(new Field("A", "X", =A0=A0=A0=A0=A0=A0=A0=A0=A0 Field.Store.YES, Field.Index.NO)); =A0=A0=A0=A0=A0 doc.add(new Field("B", "X", =A0=A0=A0=A0=A0=A0=A0=A0=A0 Field.Store.YES, Field.Index.NOT_ANALYZED)); =A0=A0=A0=A0=A0 doc.add(new Field("C", "X", =A0=A0=A0=A0=A0=A0=A0=A0=A0 Field.Store.YES, Field.Index.ANALYZED)); =A0=A0=A0=A0=A0 doc.add(new Field("D", "x", =A0=A0=A0=A0=A0=A0=A0=A0=A0 Field.Store.NO, Field.Index.NOT_ANALYZED)); =A0=A0=A0=A0=A0 doc.add(new Field("E", "X", =A0=A0=A0=A0=A0=A0=A0=A0=A0 Field.Store.NO, Field.Index.ANALYZED)); =A0=A0=A0=A0=A0 writer.addDocument(doc); =A0=A0=A0=A0=A0 writer.close(); =A0=A0=A0=A0=A0 IndexSearcher searcher =3D new IndexSearcher(idx); =A0=A0=A0=A0=A0 String field =3D "B"; =A0=A0=A0=A0=A0 QueryParser parser =3D new QueryParser(field, analyzer); =A0=A0=A0=A0=A0 Query query =3D parser.parse("X"); =A0=A0=A0=A0=A0 System.out.println("Query: " + query.toString()); =A0=A0=A0=A0=A0 TopDocCollector collector =3D new TopDocCollector(1); =A0=A0=A0=A0=A0 searcher.search(query, collector); =A0=A0=A0=A0=A0 int numHits =3D collector.getTotalHits(); =A0=A0=A0=A0=A0 System.out.println(numHits + " total matching documents"); =A0=A0=A0=A0=A0 if ( numHits > 0) =A0=A0=A0=A0=A0 { =A0=A0=A0=A0=A0=A0=A0 ScoreDoc[] hits =3D collector.topDocs().scoreDocs; =A0=A0=A0=A0=A0=A0=A0 doc =3D searcher.doc(hits[0].doc); =A0=A0=A0=A0=A0=A0=A0 System.out.println("A: " + doc.get("A")); =A0=A0=A0=A0=A0=A0=A0 System.out.println("B: " + doc.get("B")); =A0=A0=A0=A0=A0=A0=A0 System.out.println("C: " + doc.get("C")); =A0=A0=A0=A0=A0=A0=A0 System.out.println("D: " + doc.get("D")); =A0=A0=A0=A0=A0=A0=A0 System.out.println("E: " + doc.get("E")); =A0=A0=A0=A0=A0 } =A0=A0=A0 } =A0=A0=A0 catch (Exception e) =A0=A0=A0 { =A0=A0=A0=A0=A0 System.out.println(" caught a " + e.getClass() + "\n with m= essage: " =A0=A0=A0=A0=A0=A0=A0=A0=A0 + e.getMessage()); =A0=A0=A0 } =A0 } } --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org