Return-Path: Delivered-To: apmail-jakarta-lucene-user-archive@apache.org Received: (qmail 87087 invoked from network); 4 Dec 2001 13:08:37 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 4 Dec 2001 13:08:37 -0000 Received: (qmail 982 invoked by uid 97); 4 Dec 2001 13:08:36 -0000 Delivered-To: qmlist-jakarta-archive-lucene-user@jakarta.apache.org Received: (qmail 941 invoked by uid 97); 4 Dec 2001 13:08:35 -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 930 invoked from network); 4 Dec 2001 13:08:34 -0000 From: "Anders Nielsen" To: "Lucene Users List" Subject: RE: prefix query with multiple words Date: Tue, 4 Dec 2001 14:09:21 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) In-reply-to: Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N I've made a "hack"-solution for this. It basically makes a BooleanQuery with alot of OR-branches. Each OR option corresponds to a complete phrase, and like in the code for PrefixQuery I take the last term in the phrase I want to search for and make a TermEnumeration and find all the terms that has the search-term as the prefix. For each of those I make a complete PhraseQuery. A solution where it was possible to add an array of terms instead of a single term, to a PhraseQuery would most likely perform alot better. ------------------------------------- public class PhrasePrefixQuery { public static Query getQuery(IndexReader reader, Term[] terms) { Term prefixTerm = terms[terms.length-1]; TermEnum enum = null; BooleanQuery result = new BooleanQuery(); try { enum = reader.terms(prefixTerm); do { Term term = enum.term(); if (term != null && term.text().startsWith(prefixTerm.text()) && term.field() == prefixTerm.field()) { PhraseQuery pq = new PhraseQuery(); for (int i=0;i +artist:eric +artist:clap*), but this also gives you results that have the phrase in the wrong order (i.e. returns results with artist "clap eric") Is there any way to do this right? Thanks, Tom _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- To unsubscribe, e-mail: For additional commands, e-mail: -- To unsubscribe, e-mail: For additional commands, e-mail: