Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 89979 invoked from network); 6 May 2009 08:50:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 6 May 2009 08:50:36 -0000 Received: (qmail 39943 invoked by uid 500); 6 May 2009 08:50:34 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 39894 invoked by uid 500); 6 May 2009 08:50:33 -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 39880 invoked by uid 99); 6 May 2009 08:50:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 May 2009 08:50:33 +0000 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: local policy) Received: from [130.37.20.29] (HELO asterix.few.vu.nl) (130.37.20.29) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 May 2009 08:50:24 +0000 Received: from laurah.demon.nl ([83.160.148.80] helo=[192.168.123.196]) by asterix.few.vu.nl with esmtpsa (TLS-1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.63) (envelope-from ) id 1M1cpG-0002q8-8W for java-user@lucene.apache.org; Wed, 06 May 2009 10:50:02 +0200 Message-Id: <1FD944C6-DDB2-4595-8CCF-D5C4CAA15378@cs.vu.nl> From: Laura Hollink To: java-user@lucene.apache.org Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) Subject: Exact match on entire field Date: Wed, 6 May 2009 10:50:00 +0200 X-Mailer: Apple Mail (2.930.3) X-Virus-Checked: Checked by ClamAV on apache.org Hi, I am trying to distinguish between a document that matches the query because the query *appears* in one of the fields, and a document that matches the query because the query equals the complete field. I do want to use an Analyzer for case- and punctuation normalization. For example: The query "bloemendaal" matches the complete field "Bloemendaal" in a document in my result list. The query "adele" only partly matches the field "Adele Bloemendaal" in another document. What is the best way to do this? I currently solve it by first searching in a normal way, and than using the QueryParser on both the query and the relevant field in the documents in my result list. Finally, I simply compare the parsed query and the parsed field. QueryParser parser = new QueryParser(field,new StandardAnalyzer()); Query query = parser.parse(q); Hits hits = is.search(query); ... Document doc = hits.doc(i); Query myfield = parser.parse(doc.get("skos:prefLabel")); if(myfield.equals(query)) System.out.println("Query exactly matches the entire field."); else System.out.println("The field contains the query."); Is there a better way? Thanks, Laura --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org