Return-Path: Delivered-To: apmail-jakarta-lucene-user-archive@apache.org Received: (qmail 62074 invoked from network); 15 Nov 2002 15:30:29 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 15 Nov 2002 15:30:29 -0000 Received: (qmail 23137 invoked by uid 97); 15 Nov 2002 15:31:23 -0000 Delivered-To: qmlist-jakarta-archive-lucene-user@jakarta.apache.org Received: (qmail 23114 invoked by uid 97); 15 Nov 2002 15:31:22 -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 23099 invoked by uid 98); 15 Nov 2002 15:31:21 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Message-ID: <016701c28cbc$a5112620$0200a8c0@aaron> From: "Aaron Galea" To: "Lucene Users List" References: Subject: Re: Searching with Multiple Queries Date: Fri, 15 Nov 2002 16:35:36 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.3018.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.3018.1300 X-Declude-Sender: agale@nextgen.net.mt [80.77.199.204] X-Declude-Spoolname: D12fabeca035e7092.SMD X-Note: This E-mail was scanned by NextGen.net JunkMail Server for spam. X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hi Rob Here is how I think in my case I will do it but the code is not tested so it might not work: 1. Create a filter class class SearcherFilter extends Filter { protected String Directory; public SearcherFilter(String dir) { Directory = dir; } public BitSet bits(IndexReader reader) throws IOException { BitSet bits = new BitSet(reader.maxDoc()); TermDocs termDocs = reader.termDocs(); while (termDocs.next()) { int iDoc = termDocs.doc(); org.apache.lucene.document.Document doc = reader.document(iDoc); Field fldDirectory = doc.getField("Directory"); String str = fldDirectory.stringValue(); if (str.startsWith(Directory)){ bits.set(iDoc); } } return bits; } } 2. Create an Anlayzer class class SearcherAnalyzer extends Analyzer { /* * An array containing some common words that * are not usually useful for searching. */ private static final String[] STOP_WORDS = { "a" , "and" , "are" , "as" , "at" , "be" , "but" , "by" , "for" , "if" , "in" , "into" , "is" , "it" , "no" , "not" , "of" , "on" , "or" , "s" , "such" , "t" , "that" , "the" , "their" , "then" , "there" , "these" , "they" , "this" , "to" , "was" , "will" , "with" }; /* * Stop table */ final static private Hashtable stopTable = StopFilter.makeStopTable(STOP_WORDS); /* * create a token stream for this analyser */ public final TokenStream tokenStream(final Reader reader) { try { TokenStream result = new StandardTokenizer(reader); result = new StandardFilter(result); result = new LowerCaseFilter(result); result = new StopFilter(result,stopTable); result = new PorterStemFilter(result); return result; } catch (Exception e) { return null; } } } 3. In the main code use it this way: IndexSearcher searcher =new IndexSearcher(indexLocation); Query qry = QueryParser.parse(question, "body", new SearcherAnalyzer()); Hits hits = searcher.search(qry, new SearcherFilter(directory)); In your case if you do not want for example to use the LetterTokenizer() do not included in the tokenStream method of the Anlayzer. Hope this helps, Aaron ----- Original Message ----- From: "Rob Outar" To: "Lucene Users List" Sent: Friday, November 15, 2002 4:13 PM Subject: RE: Searching with Multiple Queries > For example JGuru has this: > > public class MyAnalyzer extends Analyzer > { > private static final Analyzer STANDARD = new StandardAnalyzer(); > > public TokenStream tokenStream(String field, final Reader reader) > { > // do not tokenize field called 'element' > if ("element".equals(field)) > { > return new CharTokenizer(reader) > { > protected boolean isTokenChar(char c) > { > return true; > } > }; > } > else > { > // use standard analyzer > return STANDARD.tokenStream(field, reader); > } > } > } > > > I do not want any of my fields toekenized for now, so I was thinking about > use the above code with a few slight modifications... > > Thanks, > > Rob > > > -----Original Message----- > From: Rob Outar [mailto:routar@ideorlando.org] > Sent: Friday, November 15, 2002 10:10 AM > To: Lucene Users List > Subject: RE: Searching with Multiple Queries > > > I thought this was my problem :-), anyhow can I just write an analyzer tha t > does not tokenize the search string and use it with QueryPaser? > > Thanks, > > Rob > > -----Original Message----- > From: Aaron Galea [mailto:agale@nextgen.net.mt] > Sent: Friday, November 15, 2002 9:44 AM > To: Lucene Users List > Subject: Re: Searching with Multiple Queries > > > Ok I will let you know the result.... > > thanks > Aaron > ----- Original Message ----- > From: "Otis Gospodnetic" > To: "Lucene Users List" > Sent: Friday, November 15, 2002 3:37 PM > Subject: Re: Searching with Multiple Queries > > > > I say: try it :) > > > > Otis > > > > --- Aaron Galea wrote: > > > I am not sure but I was going to do it by using a QueryParser and > > > creating a > > > filter that iterates over the documents. For each document I check > > > the > > > directory field and use the String.startsWith() function to make it > > > kinda > > > work like Prefix query. The Query and the Filter are then used in the > > > IndexSearcher. Have not tried it yet but I think it will work, what > > > do you > > > say? > > > > > > Thanks > > > Aaron > > > > > > > > > ----- Original Message ----- > > > From: "Otis Gospodnetic" > > > To: "Lucene Users List" > > > Sent: Friday, November 15, 2002 3:06 PM > > > Subject: Re: Searching with Multiple Queries > > > > > > > > > > Sounds like 2 queries to me. > > > > You could do a prefix AND phrase, but that won't be exactly the > > > same as > > > > doing a phrase query on subset of results of prefix query. > > > > > > > > Otis > > > > > > > > --- Aaron Galea wrote: > > > > > Hi everyone, > > > > > > > > > > I have indexed my documents using a hierarchical indexing by > > > adding a > > > > > directory field that is indexible but non-tokenized as suggested > > > in > > > > > the FAQ. Now I want to do a search first using a prefix query and > > > > > then apply Phrase query on the returning results. Is this > > > possible? > > > > > Can it be applied at one go? Not sure whether > > > MultiFieldQueryParser > > > > > can be used this way. Any suggestions??? > > > > > > > > > > Thanks > > > > > Aaron > > > > > > > > > > > > > > > > > __________________________________________________ > > > > Do you Yahoo!? > > > > Yahoo! Web Hosting - Let the expert host your site > > > > http://webhosting.yahoo.com > > > > > > > > -- > > > > To unsubscribe, e-mail: > > > > > > > For additional commands, e-mail: > > > > > > > > > > > --- > > > > [This E-mail was scanned for spam and viruses by NextGen.net.] > > > > > > > > > > > > > > > > > > > > > --- > > > [This E-mail was scanned for spam and viruses by NextGen.net.] > > > > > > > > > -- > > > To unsubscribe, e-mail: > > > > > > For additional commands, e-mail: > > > > > > > > > > > > __________________________________________________ > > Do you Yahoo!? > > Yahoo! Web Hosting - Let the expert host your site > > http://webhosting.yahoo.com > > > > -- > > To unsubscribe, e-mail: > > > For additional commands, e-mail: > > > > > --- > > [This E-mail was scanned for spam and viruses by NextGen.net.] > > > > > > > > > --- > [This E-mail was scanned for spam and viruses by NextGen.net.] > > > -- > To unsubscribe, e-mail: > > For additional commands, e-mail: > > > > -- > To unsubscribe, e-mail: > > For additional commands, e-mail: > > > > -- > To unsubscribe, e-mail: > For additional commands, e-mail: > > --- > [This E-mail was scanned for spam and viruses by NextGen.net.] > > > --- [This E-mail was scanned for spam and viruses by NextGen.net.] -- To unsubscribe, e-mail: For additional commands, e-mail: