Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 99212 invoked from network); 11 Sep 2007 16:55:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Sep 2007 16:55:05 -0000 Received: (qmail 38902 invoked by uid 500); 11 Sep 2007 16:54:53 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 38861 invoked by uid 500); 11 Sep 2007 16:54:53 -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 38850 invoked by uid 99); 11 Sep 2007 16:54:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Sep 2007 09:54:53 -0700 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of kohan.massoud@gmail.com designates 64.233.162.231 as permitted sender) Received: from [64.233.162.231] (HELO nz-out-0506.google.com) (64.233.162.231) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Sep 2007 16:54:48 +0000 Received: by nz-out-0506.google.com with SMTP id i28so656204nzi for ; Tue, 11 Sep 2007 09:54:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=Xh9RKjnb/KhcoTQeIqAJfKs1QRlBhE8aFRN65ySyY7s=; b=eHuGDHIppnQBVCqNUzqhNC/Be2a+CnkN4E+i2vd146A3gG3HGS3ivFK+5psOl9KX4kK+vjBuV69XbAMO8nx8TxIupOFVRMIo0AeqLOd7v9XyI4BM/uFMIaENNDKm54turkLPUymcbfxnPgwFZGA8bbUGV73spgtWkZeRSeC7lCs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=Kn79Zbs+kUTx32M+5zZdR7ZkP4khFxnEM2/GpFYMvQnpQMUOqw7JkmttcvosmlGxVCO3noR3BZsOqFpAsGsw7NE4oBml35xKlmL6ndChxtDaOL+bCJNW0TOyY8fOpM2Oix1qDnNqofy7mGvHOb89qviCab+hj3goTqINZDxiFRo= Received: by 10.65.232.19 with SMTP id j19mr12416316qbr.1189529666718; Tue, 11 Sep 2007 09:54:26 -0700 (PDT) Received: by 10.64.253.14 with HTTP; Tue, 11 Sep 2007 09:54:26 -0700 (PDT) Message-ID: <60f15f3e0709110954s6783157fif4070296ba26cb93@mail.gmail.com> Date: Tue, 11 Sep 2007 09:54:26 -0700 From: M.K To: java-user@lucene.apache.org Subject: Re: Implement a filter to the search results In-Reply-To: <359a92830709110951y3f9c47es292ec86b4bc299bd@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_15759_21072427.1189529666717" References: <60f15f3e0709101302h70d5fdc2oc97526146f0b853d@mail.gmail.com> <12606295.post@talk.nabble.com> <60f15f3e0709110859y3b134f34te32bafa5b4ffa58c@mail.gmail.com> <359a92830709110928g3140191q7249217d0efbec18@mail.gmail.com> <60f15f3e0709110945h110c4d41wc997671c8abd0616@mail.gmail.com> <359a92830709110951y3f9c47es292ec86b4bc299bd@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_15759_21072427.1189529666717 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Thanks Erick. MK On 9/11/07, Erick Erickson wrote: > > Well, it depends upon how you indexed things .... > > Your previous post was along the right lines as > far as I can see though... > > Erick > > Assuming that you have > > On 9/11/07, M. K wrote: > > > > Lucene 1.4.3 > > > > ignor the filter words. > > My question was: > > I have a search form which has an input area for key search and also > three > > optional select boxs *Catagory, Department and Year. * > > How can I implement that? Is it correct the way I wrote in my last > email. > > Thanks, > > MK > > > > > > > > On 9/11/07, Erick Erickson wrote: > > > > > > What version of Lucene are you using? I don't think the form > > > b.add(query, false, false) is current. > > > > > > Be that as it may, I'm not quite sure what you mean by > > > filter. If I'm reading your intent correctly, wouldn't requiring > > > each non-empty field accomplish what you want? Which would > > > be something like > > > b.add(query, BooleanClause.MUST); > > > > > > Best > > > Erick > > > > > > On 9/11/07, M. K wrote: > > > > > > > > I am not sure, I understant perfectly. > > > > Is this the way you said: > > > > > > > > > > > > document.add(Field.*UnStored*("text", docText)); > > > > document.add(Field.*Text*("category", category)); > > > > document.add(Field.*Text*("department",department)); > > > > document.add(Field.*Text*("year", year)); > > > > > > > > *search:* > > > > > > > > > > > > String[] fields = { "text", "category","department","year" }; > > > > > > > > BooleanQuery bQuery = *new* BooleanQuery(); > > > > > > > > *for* (*int* i = 0; i < fields.length; i++) { > > > > > > > > QueryParser parser = *new* QueryParser(fields[i], analyzer); > > > > > > > > Query q = parser.parse(query); > > > > > > > > bQuery.add(q, *false*, *false*); // combine the queries, neither > > > requiring > > > > or prohibiting matches > > > > > > > > } > > > > Hits hits = searcher.search(bQuery); > > > > > > > > > > > > MK > > > > > > > > > > > > > > > > On 9/10/07, testn wrote: > > > > > > > > > > > > > > > It's probably easier to add category, department, year as a part > of > > > > query > > > > > and > > > > > then requery to get the hits you need. > > > > > > > > > > M.K wrote: > > > > > > > > > > > > Hi All, > > > > > > > > > > > > I have a search form which has an input area for key search and > > also > > > > > > three > > > > > > optional select boxs *Catagory, Department and Year. * > > > > > > My question is how can I filter the results if users select a > > > > category > > > > > or > > > > > > a department or a year or a combination of them. > > > > > > > > > > > > *index *: > > > > > > > > > > > > IndexWriter indexWriter = > > > > > > *new* IndexWriter(API.*getRootPath*() + "\\data\\LUCENE" , > > > > > > *new*StandardAnalyzer(),true); > > > > > > > > > > > > Document document = *new* Document(); > > > > > > > > > > > > document.add(Field.*Text*("text", docText)); > > > > > > > > > > > > document.add(Field.*UnIndexed*("department", depart)); > > > > > > > > > > > > document.add(Field.*UnIndexed*( > > > > > > "category", courseId)); > > > > > > > > > > > > document.add(Field.*UnIndexed*( > > > > > > "year", year)); > > > > > > > > > > > > indexWriter.addDocument(document); > > > > > > > > > > > > indexWriter.close(); > > > > > > > > > > > > > > > > > > > > > > > > *search: * > > > > > > > > > > > > *Searcher searcher = new IndexSearcher(API.getRootPath() + > > > > > > "/data/LUCENE/"); > > > > > > Analyzer analyzer = new StandardAnalyzer();* > > > > > > > > > > > > * Query query = QueryParser.parse(request.getParameter("query"), > > > > "text", > > > > > > analyzer); > > > > > > Hits hits = searcher.search (query);* > > > > > > > > > > > > I do not konw how implement a filter to the results of the > search > > > for > > > > > > catgory or year or department. > > > > > > > > > > > > Thanks, > > > > > > > > > > > > Massoud > > > > > > > > > > > > > > > > > > > > > > -- > > > > > View this message in context: > > > > > > > > > > > > > > > http://www.nabble.com/Implement-a-filter-to-the-search-results-tf4418068.html#a12606295 > > > > > 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 > > > > > > > > > > > > > > > > > > > > ------=_Part_15759_21072427.1189529666717--