Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 42253 invoked from network); 13 May 2007 09:02:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 May 2007 09:02:58 -0000 Received: (qmail 14286 invoked by uid 500); 13 May 2007 09:02:55 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 14243 invoked by uid 500); 13 May 2007 09:02:55 -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 14231 invoked by uid 99); 13 May 2007 09:02:55 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 13 May 2007 02:02:55 -0700 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=FROM_HAS_ULINE_NUMS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [66.111.4.25] (HELO out1.smtp.messagingengine.com) (66.111.4.25) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 13 May 2007 02:02:47 -0700 Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id 806A9220027 for ; Sun, 13 May 2007 05:02:38 -0400 (EDT) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute1.internal (MEProxy); Sun, 13 May 2007 05:02:27 -0400 X-Sasl-enc: RaFbu/8YXaGKbNnaD1MpWOFSPNeArDe+2EriSs2ercnP 1179046947 Received: from [192.168.2.36] (cpc1-leed4-0-0-cust390.leed.cable.ntl.com [81.105.105.135]) by mail.messagingengine.com (Postfix) with ESMTP id 1CC592A77D for ; Sun, 13 May 2007 05:02:27 -0400 (EDT) Message-ID: <4646D424.7090609@fastmail.fm> Date: Sun, 13 May 2007 10:02:28 +0100 From: Paul Taylor Reply-To: paul_t100@fastmail.fm User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: java-user@lucene.apache.org Subject: Re: Problem using wildcardsearch in phrase search References: <4645F33E.50300@fastmail.fm> <46462379.207@gmail.com> <359a92830705121742n6836ad09sf9fed028f03506ac@mail.gmail.com> <46466721.7090707@gmail.com> In-Reply-To: <46466721.7090707@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org I think the KeywordAnlyser bit is maybe a red herring, the problem seems to be that you cant use * within double quotes, I made some changes to my data and index to remove the space character If I fed 54:puid* to my code it generates a Prefix Query and works as required Search Query Is54:puid* Parsed Search Query Is54:puid*of type:class org.apache.lucene.search.PrefixQuery but with the quotes (which I would need if my value contained spaces) I only get a Term Query (which doesnt handle wildcards) Search Query Is54:"puid*" Parsed Search Query Is54:puid*of type:class org.apache.lucene.search.TermQuery so why is this ? thanks Paul code is: public List generalSearch(String luceneSearch) { System.out.println("Search Query Is"+luceneSearch); List matchingRows = new ArrayList(); try { //make a new index searcher with the inmemory (RAM) index. IndexSearcher is = new IndexSearcher(directory); //Build a query based on the searchString and cached analyzer QueryParser parser = new QueryParser(ROW_NUMBER,analyzer); Query query = parser.parse(luceneSearch); System.out.println("Parsed Search Query Is"+query.toString()+"of type:"+query.getClass()); //run the search Hits hits = is.search(query); Iterator i = hits.iterator(); while(i.hasNext()) { Document doc = ((Hit)i.next()).getDocument(); matchingRows.add(new Integer(doc.getField(ROW_NUMBER).stringValue())); } } catch (Exception e) { e.printStackTrace(); } System.out.println("Search Query Results Set:"+matchingRows.size()); return matchingRows; } Mark Miller wrote: > >> >> >> Perhaps not like whitespaceanalyzer does in all cases, but this code >> >> QueryParser qp = new QueryParser("field", new >> WhitespaceAnalyzer()); >> >> Query q = qp.parse("Does this tokenize*"); >> System.out.println(q.toString()); >> >> produces >> >> field:Does field:this field:tokenize* >> >> >> >> while this code >> QueryParser qp = new QueryParser("field", new >> KeywordAnalyzer()); >> >> Query q = qp.parse("Does this tokenize*"); >> System.out.println(q.toString()); >> >> >> Produces: >> field:Does field:this field:tokenize* >> >> The only difference is using KeywordAnalyzer rather than >> WhitespaceAnalyzer. >> >> I sure don't see the difference, and it's puzzled me on and off. >> >> Erick > QueryParser breaks up "Does this tokenize*" before it even gets to the > Analyzer...each space separated term is fed to the analyzer one at a > time...unless they are surrounded in quotes in which case the whole > string in the quotes is fed into the analyzer. > > - Mark > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > For additional commands, e-mail: java-user-help@lucene.apache.org > > > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org