You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by kl...@apache.org on 2006/11/04 00:44:11 UTC

svn commit: r471059 - in /incubator/solr/trunk: CHANGES.txt src/java/org/apache/solr/core/SolrCore.java src/test/org/apache/solr/BasicFunctionalityTest.java

Author: klaas
Date: Fri Nov  3 15:44:11 2006
New Revision: 471059

URL: http://svn.apache.org/viewvc?view=rev&rev=471059
Log:
BugFix: field boosts were being ignored and doc boosts applied to fields rather than the doc 
(testcase + fix)

Modified:
    incubator/solr/trunk/CHANGES.txt
    incubator/solr/trunk/src/java/org/apache/solr/core/SolrCore.java
    incubator/solr/trunk/src/test/org/apache/solr/BasicFunctionalityTest.java

Modified: incubator/solr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/CHANGES.txt?view=diff&rev=471059&r1=471058&r2=471059
==============================================================================
--- incubator/solr/trunk/CHANGES.txt (original)
+++ incubator/solr/trunk/CHANGES.txt Fri Nov  3 15:44:11 2006
@@ -112,6 +112,7 @@
  7. WordDelimiterFilter can throw exceptions if configured with both
     generate and catenate off.  (Mike Klaas via yonik, SOLR-34)
  8. Escape '>' in XML output (because ]]> is illegal in CharData) 
+ 9. field boosts weren't being applied and doc boosts were being applied to fields (klaas)
 
 Other Changes
  1. Upgrade to Lucene 2.0 nightly build 2006-06-22, lucene SVN revision 416224,

Modified: incubator/solr/trunk/src/java/org/apache/solr/core/SolrCore.java
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/src/java/org/apache/solr/core/SolrCore.java?view=diff&rev=471059&r1=471058&r2=471059
==============================================================================
--- incubator/solr/trunk/src/java/org/apache/solr/core/SolrCore.java (original)
+++ incubator/solr/trunk/src/java/org/apache/solr/core/SolrCore.java Fri Nov  3 15:44:11 2006
@@ -864,6 +864,7 @@
       String attrVal = xpp.getAttributeValue(i);
       if ("boost".equals(attrName)) {
         docBoost = Float.parseFloat(attrVal);
+        builder.setBoost(docBoost);
       } else {
         log.warning("Unknown attribute doc/@" + attrName);
       }
@@ -911,8 +912,8 @@
                                         // need this line for isNull???
       // Don't add fields marked as null (for now at least)
       if (!isNull) {
-        if (docBoost != 1.0f) {
-          builder.addField(name,val,docBoost);
+        if (boost != 1.0f) {
+          builder.addField(name,val,boost);
         } else {
           builder.addField(name,val);
         }

Modified: incubator/solr/trunk/src/test/org/apache/solr/BasicFunctionalityTest.java
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/src/test/org/apache/solr/BasicFunctionalityTest.java?view=diff&rev=471059&r1=471058&r2=471059
==============================================================================
--- incubator/solr/trunk/src/test/org/apache/solr/BasicFunctionalityTest.java (original)
+++ incubator/solr/trunk/src/test/org/apache/solr/BasicFunctionalityTest.java Fri Nov  3 15:44:11 2006
@@ -157,6 +157,43 @@
 
   }
 
+  public void testDocBoost() throws Exception {
+    String res = h.update("<add>" + "<doc><field name=\"id\">1</field>"+
+                                          "<field name=\"text\">hello</field></doc>" + 
+                          "<doc boost=\"2.0\"><field name=\"id\">2</field>" +
+                                          "<field name=\"text\">hello</field></doc>" + 
+                          "</add>");
+
+    assertEquals("<result status=\"0\"></result><result status=\"0\"></result>", res);
+    assertU("<commit/>");
+    assertQ(req("text:hello")
+            ,"//*[@numFound='2']"
+            );
+    String resp = h.query(lrf.makeRequest("q", "text:hello", "debugQuery", "true"));
+    //System.out.println(resp);
+    // second doc ranked first
+    assertTrue( resp.indexOf("id=2") < resp.indexOf("id=1") );
+  }
+
+  public void testFieldBoost() throws Exception {
+    String res = h.update("<add>" + "<doc><field name=\"id\">1</field>"+
+                                      "<field name=\"text\">hello</field></doc>" + 
+                                    "<doc><field name=\"id\">2</field>" +
+                                      "<field boost=\"2.0\" name=\"text\">hello</field></doc>" + 
+                          "</add>");
+
+    assertEquals("<result status=\"0\"></result><result status=\"0\"></result>", res);
+    assertU("<commit/>");
+    assertQ(req("text:hello"),
+            "//*[@numFound='2']"
+            );
+    String resp = h.query(lrf.makeRequest("q", "text:hello", "debugQuery", "true"));
+    //System.out.println(resp);
+    // second doc ranked first
+    assertTrue( resp.indexOf("id=2") < resp.indexOf("id=1") );
+  }
+
+
   public void testXMLWriter() throws Exception {
 
     SolrQueryResponse rsp = new SolrQueryResponse();



Re: Re: svn commit: r471059 - in /incubator/solr/trunk: CHANGES.txt src/java/org/apache/solr/core/SolrCore.java src/test/org/apache/solr/BasicFunctionalityTest.java

Posted by Mike Klaas <mi...@gmail.com>.
On 11/3/06, Yonik Seeley <yo...@apache.org> wrote:
> > : + 9. field boosts weren't being applied and doc boosts were being applied to fields (klaas)
> >
> > Ouch!  Nice catch.
>
> Heh.  I don't think we've ever used index-time boosts in CNET.

Hopefully there aren't many features that no-one is using *g*.

-Mike

Re: svn commit: r471059 - in /incubator/solr/trunk: CHANGES.txt src/java/org/apache/solr/core/SolrCore.java src/test/org/apache/solr/BasicFunctionalityTest.java

Posted by Yonik Seeley <yo...@apache.org>.
> : + 9. field boosts weren't being applied and doc boosts were being applied to fields (klaas)
>
> Ouch!  Nice catch.

Heh.  I don't think we've ever used index-time boosts in CNET.

-Yonik

Re: svn commit: r471059 - in /incubator/solr/trunk: CHANGES.txt src/java/org/apache/solr/core/SolrCore.java src/test/org/apache/solr/BasicFunctionalityTest.java

Posted by Chris Hostetter <ho...@fucit.org>.
: + 9. field boosts weren't being applied and doc boosts were being applied to fields (klaas)

Ouch!  Nice catch.



-Hoss