Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 32797 invoked from network); 4 May 2009 15:22:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 4 May 2009 15:22:08 -0000 Received: (qmail 26355 invoked by uid 500); 4 May 2009 15:22:05 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 26313 invoked by uid 500); 4 May 2009 15:22:05 -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 26303 invoked by uid 99); 4 May 2009 15:22:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 May 2009 15:22:05 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 May 2009 15:21:57 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1M0zz7-00043J-4X for java-user@lucene.apache.org; Mon, 04 May 2009 08:21:37 -0700 Message-ID: <23370618.post@talk.nabble.com> Date: Mon, 4 May 2009 08:21:37 -0700 (PDT) From: Huntsman84 To: java-user@lucene.apache.org Subject: Re: Searching for partial matches In-Reply-To: <8c4e68610904300409u6852af5exc67cb29bcf3e15fc@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: tpgarcia84@gmail.com References: <23313810.post@talk.nabble.com> <8c4e68610904300409u6852af5exc67cb29bcf3e15fc@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org Hi I've tryed this with MultiPhraseQuery, but it always returns me all documents of the index, no matter what expression I use. I've read that adding a set of terms wich their values are all the entered query (e.g. "str"), the search works as the symbol "*" (e.g. "str*"), so I tryed that. My code is like this: // prompt the user System.out.println("Enter query: "); String line = in.readLine(); //if I put "str", I want all matches like "string", "strong", "astray".... line = line.trim(); //I thought this would be ok... MultiPhraseQuery mpquery = new MultiPhraseQuery(); TermEnum te = reader.terms(new Term("contents",line)); /*Home-made conversion from TermEnum to Term[]... I get just 200 matches, I don't want my machine busy...*/ Term[] terms = new Term[200]; int j=0; while(te.next() && j<200){ terms[j] = te.term(); j++; } mpquery.add(terms); Query query = parser.parse(line); System.out.println("Searching for: " + query.toString(field)); Date start = new Date(); Hits hits = searcher.search(mpquery); for(int k = 0; k<100; k++){ //when I print the results of the search, none of the values match with the query... System.out.println(hits.doc(k).getField("contents").stringValue()); } Ian Lea wrote: > > Hi > > > This is possible. There is an entry on wildcards in the FAQ. See > also RegexQuery and search the mailing lists for ngrams. > > Depending on your setup and requirements you may need to be aware of > the performance implications of wild card searching, particularly > leading wildcards as will be required for the example you give. See > the FAQ and javadocs for WildcardQuery. > > > -- > Ian. > > On Thu, Apr 30, 2009 at 11:46 AM, Huntsman84 wrote: >> >> Hello, >> >> >> >> I am new to Lucene, and I don't know if it is possible to obtain results >> providing part of the keyword. >> >> >> >> For example, if I try to search "in", it should return all matches with >> "string", "meaning", "trinity"... >> >> >> >> Am I expecting too much? >> >> >> >> Thank you so much! > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > For additional commands, e-mail: java-user-help@lucene.apache.org > > > -- View this message in context: http://www.nabble.com/Searching-for-partial-matches-tp23313810p23370618.html Sent from the Lucene - Java Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org