Class SearchEquivalenceTestBase

java.lang.Object
org.junit.Assert
org.apache.lucene.tests.util.LuceneTestCase
org.apache.lucene.tests.search.SearchEquivalenceTestBase

@SuppressCodecs("SimpleText") public abstract class SearchEquivalenceTestBase extends LuceneTestCase
Simple base class for checking search equivalence. Extend it, and write tests that create randomTerm()s (all terms are single characters a-z), and use assertSameSet(Query, Query) and assertSubsetOf(Query, Query)
  • Field Details

  • Constructor Details

    • SearchEquivalenceTestBase

      public SearchEquivalenceTestBase()
  • Method Details

    • beforeClass

      public static void beforeClass() throws Exception
      Throws:
      Exception
    • afterClass

      public static void afterClass() throws Exception
      Throws:
      Exception
    • randomTerm

      protected Term randomTerm()
      returns a term suitable for searching. terms are single characters in lowercase (a-z)
    • randomFilter

      protected Query randomFilter()
      Returns a random filter over the document set
    • assertSameSet

      public void assertSameSet(Query q1, Query q2) throws Exception
      Asserts that the documents returned by q1 are the same as of those returned by q2
      Throws:
      Exception
    • assertSubsetOf

      public void assertSubsetOf(Query q1, Query q2) throws Exception
      Asserts that the documents returned by q1 are a subset of those returned by q2
      Throws:
      Exception
    • assertSubsetOf

      protected void assertSubsetOf(Query q1, Query q2, Query filter) throws Exception
      Asserts that the documents returned by q1 are a subset of those returned by q2.

      Both queries will be filtered by filter

      Throws:
      Exception
    • assertSameScores

      protected void assertSameScores(Query q1, Query q2) throws Exception
      Assert that two queries return the same documents and with the same scores.
      Throws:
      Exception
    • assertSameScores

      protected void assertSameScores(Query q1, Query q2, Query filter) throws Exception
      Throws:
      Exception
    • filteredQuery

      protected Query filteredQuery(Query query, Query filter)