Return-Path: Delivered-To: apmail-jakarta-lucene-user-archive@www.apache.org Received: (qmail 38937 invoked from network); 8 Feb 2005 14:29:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 8 Feb 2005 14:29:49 -0000 Received: (qmail 45288 invoked by uid 500); 8 Feb 2005 14:29:36 -0000 Delivered-To: apmail-jakarta-lucene-user-archive@jakarta.apache.org Received: (qmail 45261 invoked by uid 500); 8 Feb 2005 14:29:36 -0000 Mailing-List: contact lucene-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Lucene Users List" Reply-To: "Lucene Users List" Delivered-To: mailing list lucene-user@jakarta.apache.org Received: (qmail 45247 invoked by uid 99); 8 Feb 2005 14:29:36 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from lyra.lunarpages.com (HELO lyra.lunarpages.com) (64.235.230.140) by apache.org (qpsmtpd/0.28) with ESMTP; Tue, 08 Feb 2005 06:29:34 -0800 Received: from mueasd-wan184.citykom.de ([195.202.35.184] helo=Kelvin) by lyra.lunarpages.com with esmtpa (Exim 4.44) id 1CyWMs-0007mH-A3 for lucene-user@jakarta.apache.org; Tue, 08 Feb 2005 06:29:31 -0800 From: Kelvin Tan To: Lucene Users List X-Mailer: Barca 1.1 (840) - Licensed Version Date: Tue, 8 Feb 2005 15:29:10 +0100 Message-ID: <200528152910.623968@Kelvin> In-Reply-To: Subject: Re: Problem searching Field.Keyword field Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - lyra.lunarpages.com X-AntiAbuse: Original Domain - jakarta.apache.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - relevanz.com X-Source: X-Source-Args: X-Source-Dir: X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Javadocs for Field.Keyword says: Constructs a Date-valued Field that is not tokenized and is indexed, and= stored in the index, for return with hits. For most purposes dealing with Strings, use Field.Text, unless you have a= date, a GUID or some other string you don't want tokenized or processed in= any way. This basically means that Field.Keyword indexes the field as-is. k On Tue, 8 Feb 2005 07:54:57 -0600, Mike Miller wrote: >=A0First let me say - Awesome tool! =A0Almost too easy to be true, but >=A0with that being said.... > >=A0Hi, =A0I have read several articles and postings that indicate that >=A0the Field.Keyword field should be searchable but it's not working >=A0for me, until I change to Field.Text. =A0Parts of the index and >=A0search code are included below - mostly lifted from articles,etc, >=A0including Erik Hatches article on java.net. =A0 I created a small >=A0KnowledgeBase web application that contains a category field, which >=A0I want to be searchable. Searching using a query string of >=A0category:Doc* or >=A0category:Documentation does not find a hit unless I change the code >=A0to add the category to the index as a Field.Text instead of >=A0Field.Keyword. The field value is out there: =A0 I have verified this >=A0using the TermEnum to list the term values for field category and >=A0Documentation is in the list of values. > >=A0The intention is to provide a 'Advanced Search' page that allows >=A0the user to search specific fields, like category, title and author >=A0instead of always using the 'all' field. > >=A0What am I doing wrong??? =A0 =A0 Thanks in advance. > >=A0Index code: > >=A0public boolean index(ArticleFormBean article) throws IOException { >=A0IndexWriter writer =3D new IndexWriter(indexDir, new >=A0StandardAnalyzer(), false); > >=A0Document doc =3D new Document(); >=A0doc.add(Field.UnStored("content", article.getContent())); >=A0doc.add(Field.Text("title", article.getTitle())); >=A0doc.add(Field.Text("author", article.getAuthor())); >=A0doc.add(Field.UnIndexed("articleId", >=A0String.valueOf(article.getArticleId()))); >=A0doc.add(Field.Keyword("createdDate", article.getCreateDate())); >=A0doc.add(Field.Keyword("modDate", article.getModDate())); >=A0doc.add(Field.Keyword("category", article.getCategory())); > >=A0// create an 'all' field >=A0StringBuffer sb =3D new StringBuffer(4000); >=A0sb.append(article.getTitle()).append(" >=A0").append(article.getAuthor()).append(" "); >=A0sb.append(article.getContent()).append(" >=A0").append(article.getCategory()); >=A0doc.add(Field.UnStored("all", sb.toString())); > >=A0writer.addDocument(doc); >=A0writer.optimize(); >=A0writer.close(); > >=A0return false; >=A0} > >=A0Search code: >=A0File indexDir =3D new File("c:/dev/java/kb/index"); Directory fsDir =3D >=A0FSDirectory.getDirectory(indexDir, false); IndexSearcher is =3D new >=A0IndexSearcher(fsDir); Query query =3D QueryParser.parse(q, "all", new >=A0StandardAnalyzer()); Hits hits =3D is.search(query); > > >=A0Mike Miller >=A0JDA Software Group, Inc. >=A07501 Ester's Blvd, Suite 100 >=A0Irving, Texas 75063 --------------------------------------------------------------------- To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: lucene-user-help@jakarta.apache.org