Class FunctionScoreQuery

java.lang.Object
org.apache.lucene.search.Query
org.elasticsearch.common.lucene.search.function.FunctionScoreQuery

public class FunctionScoreQuery
extends org.apache.lucene.search.Query
A query that allows for a pluggable boost function / filter. If it matches the filter, it will be boosted by the formula.
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static class  FunctionScoreQuery.FilterScoreFunction  
    static class  FunctionScoreQuery.ScoreMode  
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static float DEFAULT_MAX_BOOST  
  • Constructor Summary

    Constructors 
    Constructor Description
    FunctionScoreQuery​(org.apache.lucene.search.Query subQuery, java.lang.Float minScore, float maxBoost)
    Creates a FunctionScoreQuery without function.
    FunctionScoreQuery​(org.apache.lucene.search.Query subQuery, FunctionScoreQuery.ScoreMode scoreMode, ScoreFunction[] functions, CombineFunction combineFunction, java.lang.Float minScore, float maxBoost)
    Creates a FunctionScoreQuery with multiple score functions
    FunctionScoreQuery​(org.apache.lucene.search.Query subQuery, ScoreFunction function)
    Creates a FunctionScoreQuery with a single ScoreFunction
    FunctionScoreQuery​(org.apache.lucene.search.Query subQuery, ScoreFunction function, CombineFunction combineFunction, java.lang.Float minScore, float maxBoost)
    Creates a FunctionScoreQuery with a single function
  • Method Summary

    Modifier and Type Method Description
    org.apache.lucene.search.Weight createWeight​(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.ScoreMode scoreMode, float boost)  
    boolean equals​(java.lang.Object o)  
    CombineFunction getCombineFunction()  
    ScoreFunction[] getFunctions()  
    java.lang.Float getMinScore()  
    org.apache.lucene.search.Query getSubQuery()  
    int hashCode()  
    org.apache.lucene.search.Query rewrite​(org.apache.lucene.index.IndexReader reader)  
    java.lang.String toString​(java.lang.String field)  
    void visit​(org.apache.lucene.search.QueryVisitor visitor)  

    Methods inherited from class org.apache.lucene.search.Query

    classHash, sameClassAs, toString

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • FunctionScoreQuery

      public FunctionScoreQuery​(org.apache.lucene.search.Query subQuery, java.lang.Float minScore, float maxBoost)
      Creates a FunctionScoreQuery without function.
      Parameters:
      subQuery - The query to match.
      minScore - The minimum score to consider a document.
      maxBoost - The maximum applicable boost.
    • FunctionScoreQuery

      public FunctionScoreQuery​(org.apache.lucene.search.Query subQuery, ScoreFunction function)
      Creates a FunctionScoreQuery with a single ScoreFunction
      Parameters:
      subQuery - The query to match.
      function - The ScoreFunction to apply.
    • FunctionScoreQuery

      public FunctionScoreQuery​(org.apache.lucene.search.Query subQuery, ScoreFunction function, CombineFunction combineFunction, java.lang.Float minScore, float maxBoost)
      Creates a FunctionScoreQuery with a single function
      Parameters:
      subQuery - The query to match.
      function - The ScoreFunction to apply.
      combineFunction - Defines how the query and function score should be applied.
      minScore - The minimum score to consider a document.
      maxBoost - The maximum applicable boost.
    • FunctionScoreQuery

      public FunctionScoreQuery​(org.apache.lucene.search.Query subQuery, FunctionScoreQuery.ScoreMode scoreMode, ScoreFunction[] functions, CombineFunction combineFunction, java.lang.Float minScore, float maxBoost)
      Creates a FunctionScoreQuery with multiple score functions
      Parameters:
      subQuery - The query to match.
      scoreMode - Defines how the different score functions should be combined.
      functions - The ScoreFunctions to apply.
      combineFunction - Defines how the query and function score should be applied.
      minScore - The minimum score to consider a document.
      maxBoost - The maximum applicable boost.
  • Method Details

    • getSubQuery

      public org.apache.lucene.search.Query getSubQuery()
    • getFunctions

      public ScoreFunction[] getFunctions()
    • getMinScore

      public java.lang.Float getMinScore()
    • getCombineFunction

      public CombineFunction getCombineFunction()
    • visit

      public void visit​(org.apache.lucene.search.QueryVisitor visitor)
      Overrides:
      visit in class org.apache.lucene.search.Query
    • rewrite

      public org.apache.lucene.search.Query rewrite​(org.apache.lucene.index.IndexReader reader) throws java.io.IOException
      Overrides:
      rewrite in class org.apache.lucene.search.Query
      Throws:
      java.io.IOException
    • createWeight

      public org.apache.lucene.search.Weight createWeight​(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.ScoreMode scoreMode, float boost) throws java.io.IOException
      Overrides:
      createWeight in class org.apache.lucene.search.Query
      Throws:
      java.io.IOException
    • toString

      public java.lang.String toString​(java.lang.String field)
      Specified by:
      toString in class org.apache.lucene.search.Query
    • equals

      public boolean equals​(java.lang.Object o)
      Specified by:
      equals in class org.apache.lucene.search.Query
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in class org.apache.lucene.search.Query