java.lang.Object
org.apache.lucene.search.Query
org.elasticsearch.search.aggregations.bucket.sampler.random.RandomSamplingQuery

public final class RandomSamplingQuery extends org.apache.lucene.search.Query
A query that randomly matches documents with a user-provided probability within a geometric distribution
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    A DocIDSetIter that skips a geometrically random number of documents
  • Constructor Summary

    Constructors
    Constructor
    Description
    RandomSamplingQuery(double p, int seed, int hash)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Verifies that the probability is within the (0.0, 1.0) range.
    org.apache.lucene.search.Weight
    createWeight(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.ScoreMode scoreMode, float boost)
     
    boolean
     
    int
     
    int
     
    double
     
    int
     
     
    void
    visit(org.apache.lucene.search.QueryVisitor visitor)
     

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

    classHash, rewrite, sameClassAs, toString

    Methods inherited from class java.lang.Object

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

    • RandomSamplingQuery

      public RandomSamplingQuery(double p, int seed, int hash)
      Parameters:
      p - The sampling probability e.g. 0.05 == 5% probability a document will match
      seed - The seed from the builder
      hash - A unique hash so that if the same seed is used between multiple queries, unique random number streams can be generated
  • Method Details

    • checkProbabilityRange

      public static void checkProbabilityRange(double p) throws IllegalArgumentException
      Verifies that the probability is within the (0.0, 1.0) range.
      Throws:
      IllegalArgumentException - in case of an invalid probability.
    • probability

      public double probability()
    • seed

      public int seed()
    • hash

      public int hash()
    • toString

      public String toString(String field)
      Specified by:
      toString in class org.apache.lucene.search.Query
    • createWeight

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

      public void visit(org.apache.lucene.search.QueryVisitor visitor)
      Specified by:
      visit in class org.apache.lucene.search.Query
    • equals

      public boolean equals(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