Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 31748 invoked from network); 21 May 2005 00:05:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 21 May 2005 00:05:35 -0000 Received: (qmail 77731 invoked by uid 500); 21 May 2005 00:05:29 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 77686 invoked by uid 500); 21 May 2005 00:05:28 -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 77673 invoked by uid 99); 21 May 2005 00:05:28 -0000 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=FORGED_RCVD_HELO X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from 66-238-9-116.dia.xo.com (HELO exch01.allegro.med) (66.238.9.116) by apache.org (qpsmtpd/0.28) with ESMTP; Fri, 20 May 2005 17:05:26 -0700 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Subject: RE: Question regarding boosting Date: Fri, 20 May 2005 17:05:23 -0700 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Question regarding boosting Thread-Index: AcVddHflFQdzTPaCRleIMj2rs1uFwwAErRhQAAQl51A= From: "Mufaddal Khumri" To: X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi, After a little probing and trying I formulated this query: .... .... queryString =3D "entity:\"" + en + "\" AND (name:\"" + queryString + = "\"^2 OR content:\"" + queryString + "\")"; Query q =3D QueryParser.parse(queryString, "content", analyzer); .... .... When I execute the above query, the following query gets executed in lucene: +entity:product +(name:"audio cable"^2.0 content:"audio cable") Note: "audio cable" is the contents of the search box. Also I saw that my OR gets represented as a blank in the query. Is that fine? The results from executing this query seem alright, but is this a good way of achieving the results I was trying to achieve? (NOTE: My original post explains what I am trying to do). Any insight would be appreciated. Mufaddal. -----Original Message----- From: Mufaddal Khumri [mailto:MKhumri@allegromedical.com]=20 Sent: Friday, May 20, 2005 3:34 PM To: java-user@lucene.apache.org Subject: Question regarding boosting Hi, I wanted to know what method would be the best way to do something that I am describing below. I am creating an index of all my products and categories. While indexing, I am creating the following documents for my products and categories: Product: doc.add(Field.UnIndexed("id", (String)obj[0])); doc.add(Field.Keyword("entity","product")); doc.add(Field.Text("name", name)); doc.add(Field.Text("content", content)); Category: doc.add(Field.UnIndexed("id", (String)obj[0])); doc.add(Field.Keyword("entity","category")); doc.add(Field.Text("name", name)); doc.add(Field.Text("content", content)); As you can see above the id is stored to retrieve the objects from the database. The entity field distinguishes whether I want to carry out my search on products or categories. The content field is a combination of the name and description of the product and category. The name field is the name of the product or the name of the category. My searches and indexing works great. This is how I am searching: Query query1 =3D QueryParser.parse(queryString,"content",analyzer); =09 Term term =3D null; if(entity.equals("product")) term =3D new Term("entity","product"); else if(entity.equals("category")) term =3D new Term("entity","category"); =20 TermQuery query2 =3D new TermQuery(term);=20 BooleanQuery bq =3D new BooleanQuery(); bq.add(query1, true, false); bq.add(query2, true, false); =09 return indexSearcher.search(bq); As you can see above I am using the content and entity fields to do my search and everything works fine. What I want to do now is that I want to boost the results such that if the query matches the name field it gives a higher rank. How do I do this? For example adding something like this: ... Query query3 =3D QueryParser.parse(queryString,"name",analyzer); query3.setBoost(2); ... ... bq.add(query3, true, false); When I do the above, I print a toString on my final Boolean query which is: +content:radio +entity:category +name:radio^2.0 When I am doing my search for "products", lets say, how do I tell lucene that - "Show me all products such that the results are ordered in such a way that if a product's name matches the querystring more it gets a higher relevance" So the relevance should be in the following order: 1. Product name matches more - more relevance. 2. Product content matches - relevance is more but less than the relevance given to product name in 1. Any ideas? Thanks. ------------------------------------------------------------------------ ------------------ This email and any files transmitted with it are confidential=20 and intended solely for the use of the individual or entity=20 to whom they are addressed. If you have received this=20 email in error please notify the system manager. Please note that any views or opinions presented in this email=20 are solely those of the author and do not necessarily represent those of the company. Finally, the recipient should check this email and any attachments for the=20 presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. Consult your physician prior to the use of any medical supplies or product. ------------------------------------------------------------------------ ------------------ --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org