Return-Path: Delivered-To: apmail-jakarta-lucene-user-archive@www.apache.org Received: (qmail 7489 invoked from network); 2 Aug 2004 08:09:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 2 Aug 2004 08:09:58 -0000 Received: (qmail 36624 invoked by uid 500); 2 Aug 2004 08:09:50 -0000 Delivered-To: apmail-jakarta-lucene-user-archive@jakarta.apache.org Received: (qmail 36582 invoked by uid 500); 2 Aug 2004 08:09:49 -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 36565 invoked by uid 99); 2 Aug 2004 08:09:49 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [143.205.118.212] (HELO proserver2.ifit.uni-klu.ac.at) (143.205.118.212) by apache.org (qpsmtpd/0.27.1) with ESMTP; Mon, 02 Aug 2004 01:09:43 -0700 Received: from ifit.uni-klu.ac.at ([143.205.118.98]) by proserver2.ifit.uni-klu.ac.at over TLS secured channel with Microsoft SMTPSVC(5.0.2195.6713); Mon, 2 Aug 2004 10:10:44 +0200 Message-ID: <410DF6FD.1030404@ifit.uni-klu.ac.at> Date: Mon, 02 Aug 2004 10:10:37 +0200 From: Sergiu Gordea User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5) Gecko/20031007 X-Accept-Language: de-at, en, ro, it, en-us MIME-Version: 1.0 To: Lucene Users List Subject: Re: Having common word in the search References: <006201c47865$2128ab80$0448170a@infact12> In-Reply-To: <006201c47865$2128ab80$0448170a@infact12> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 02 Aug 2004 08:10:44.0492 (UTC) FILETIME=[35A16CC0:01C47868] X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N I have the same problem. Right now I think is not possible to do what you want by using MultifieldQueryParser. Right now I iplemented a query normalization for our product, but I consider that the best way is to take the source code and to implement: Query q = MultiFieldQueryParser.parse(line,fields,analyzer, operator); where operator can be AND / OR Another solution may be to Forget about MultifieldQueryParser, and to create an compose the correct query parser with QueryParser and BooleanQueries. MultifieldQueryParser failes in the case you search in two fileds for +a +b, because it requires that both terms to be in on of the fields. A bigger problem is in the case you want to search for "a AND NOT b" in two fields. Because these error is instantly observed by users. In the first case +a +b you will get less results then the correct one. In teh second case you will get more results (correct ones + wrong ones). There was a disscusion on this topic. Please search the mail archive. All the best, Sergiu lingaraju wrote: >Dear All > >Searcher searcher = new IndexSearcher("C:/index"); >Analyzer analyzer = new StandardAnalyzer(); >String line="curry asia"; >line=line+"recipe"; >String fields[] = new String[2]; >fields[0] = "title"; >fields[1] = "contents"; > >Query q = MultiFieldQueryParser.parse(line,fields,analyzer); >Hits hits1 = searcher.search(q); > >In the above code Hits will return the documnet that contains >the word >1)"Curry OR asia OR recipe" >2)"Curry OR asia AND recipe" >3)"Curry AND asia AND recipe" >4)"Curry AND asia OR recipe" > >But I want the result should be >Like this >1)"Curry AND asia AND recipe" >2)("Curry OR asia) AND recipe" > >My question is how to give the condition >Actually my requirement is like this >User will enter some text in "text box" it may be one word or two word or n word.(Eg "curry asia") >but when i am searching i will append "recipe" word in the search string so the search must contains "recipe" word. > >Finally search should contains >1)"Curry AND asia AND recipe" >2)("Curry OR asia) AND recipe" > >search should not contains >1)"Curry AND asia OR recipe" >2)"Curry OR asia OR recipe" > > >Thanks and regards >Raju > > --------------------------------------------------------------------- To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: lucene-user-help@jakarta.apache.org