You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Karl Wettin (JIRA)" <ji...@apache.org> on 2008/01/25 14:46:37 UTC

[jira] Updated: (LUCENE-1155) BoostingTermQuery#defaultTermBoost

     [ https://issues.apache.org/jira/browse/LUCENE-1155?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Karl Wettin updated LUCENE-1155:
--------------------------------

      Description: 
This patch allows a null payload to mean something different than 1f.

(I have this use case where 99% of my tokens share the same rather large token position payload boost.)

{code}
Index: src/java/org/apache/lucene/search/payloads/BoostingTermQuery.java
===================================================================
--- src/java/org/apache/lucene/search/payloads/BoostingTermQuery.java   (revision 615215)
+++ src/java/org/apache/lucene/search/payloads/BoostingTermQuery.java   (working copy)
@@ -41,11 +41,16 @@
  */
 public class BoostingTermQuery extends SpanTermQuery{
 
+  private Float defaultTermBoost = null;
 
   public BoostingTermQuery(Term term) {
     super(term);
   }
 
+  public BoostingTermQuery(Term term, Float defaultTermBoost) {
+    super(term);
+    this.defaultTermBoost = defaultTermBoost;
+  }
 
   protected Weight createWeight(Searcher searcher) throws IOException {
     return new BoostingTermWeight(this, searcher);
@@ -107,7 +112,9 @@
           payload = positions.getPayload(payload, 0);
           payloadScore += similarity.scorePayload(term.field(), payload, 0, positions.getPayloadLength());
           payloadsSeen++;
-
+        } else if (defaultTermBoost != null) {
+          payloadScore += defaultTermBoost;
+          payloadsSeen++;
         } else {
           //zero out the payload?
         }
@@ -146,7 +153,14 @@
 
   }
 
+  public Float getDefaultTermBoost() {
+    return defaultTermBoost;
+  }
 
+  public void setDefaultTermBoost(Float defaultTermBoost) {
+    this.defaultTermBoost = defaultTermBoost;
+  }
+
   public boolean equals(Object o) {
     if (!(o instanceof BoostingTermQuery))
       return false;
{code}


  was:
This patch allows a null payload to mean something different than 1f.

(I have this use case where 99% of my tokens share the same rather large token position payload boost.)

{code}
+++ src/java/org/apache/lucene/search/payloads/BoostingTermQuery.java   (working copy)
@@ -41,11 +41,16 @@
  */
 public class BoostingTermQuery extends SpanTermQuery{
 
+  private Float defaultTermBoost = null;
 
   public BoostingTermQuery(Term term) {
     super(term);
   }
 
+  public BoostingTermQuery(Term term, Float defaultTermBoost) {
+    super(term);
+    this.defaultTermBoost = defaultTermBoost;
+  }
 
   protected Weight createWeight(Searcher searcher) throws IOException {
     return new BoostingTermWeight(this, searcher);
@@ -107,7 +112,9 @@
           payload = positions.getPayload(payload, 0);
           payloadScore += similarity.scorePayload(term.field(), payload, 0, positions.getPayloadLength());
           payloadsSeen++;
-
+        } else if (defaultTermBoost != null) {
+          payloadScore += defaultTermBoost;
+          payloadsSeen++;
         } else {
           //zero out the payload?
         }
@@ -146,7 +153,14 @@
 
   }
 
+  public Float getDefaultTermBoost() {
+    return defaultTermBoost;
+  }
 
+  public void setDefaultTermBoost(Float defaultTermBoost) {
+    this.defaultTermBoost = defaultTermBoost;
+  }
+
   public boolean equals(Object o) {
     if (!(o instanceof BoostingTermQuery))
       return false;
{code}


    Lucene Fields: [New, Patch Available]  (was: [Patch Available, New])

missed first two lines in the diff

> BoostingTermQuery#defaultTermBoost
> ----------------------------------
>
>                 Key: LUCENE-1155
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1155
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Search
>            Reporter: Karl Wettin
>            Priority: Trivial
>
> This patch allows a null payload to mean something different than 1f.
> (I have this use case where 99% of my tokens share the same rather large token position payload boost.)
> {code}
> Index: src/java/org/apache/lucene/search/payloads/BoostingTermQuery.java
> ===================================================================
> --- src/java/org/apache/lucene/search/payloads/BoostingTermQuery.java   (revision 615215)
> +++ src/java/org/apache/lucene/search/payloads/BoostingTermQuery.java   (working copy)
> @@ -41,11 +41,16 @@
>   */
>  public class BoostingTermQuery extends SpanTermQuery{
>  
> +  private Float defaultTermBoost = null;
>  
>    public BoostingTermQuery(Term term) {
>      super(term);
>    }
>  
> +  public BoostingTermQuery(Term term, Float defaultTermBoost) {
> +    super(term);
> +    this.defaultTermBoost = defaultTermBoost;
> +  }
>  
>    protected Weight createWeight(Searcher searcher) throws IOException {
>      return new BoostingTermWeight(this, searcher);
> @@ -107,7 +112,9 @@
>            payload = positions.getPayload(payload, 0);
>            payloadScore += similarity.scorePayload(term.field(), payload, 0, positions.getPayloadLength());
>            payloadsSeen++;
> -
> +        } else if (defaultTermBoost != null) {
> +          payloadScore += defaultTermBoost;
> +          payloadsSeen++;
>          } else {
>            //zero out the payload?
>          }
> @@ -146,7 +153,14 @@
>  
>    }
>  
> +  public Float getDefaultTermBoost() {
> +    return defaultTermBoost;
> +  }
>  
> +  public void setDefaultTermBoost(Float defaultTermBoost) {
> +    this.defaultTermBoost = defaultTermBoost;
> +  }
> +
>    public boolean equals(Object o) {
>      if (!(o instanceof BoostingTermQuery))
>        return false;
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org