Class SpanTestUtil


  • public class SpanTestUtil
    extends Object
    Some utility methods used for testing span queries
    • Constructor Detail

      • SpanTestUtil

        public SpanTestUtil()
    • Method Detail

      • spanQuery

        public static SpanQuery spanQuery​(SpanQuery query)
        Adds additional asserts to a spanquery. Highly recommended if you want tests to actually be debuggable.
      • spanTermQuery

        public static SpanQuery spanTermQuery​(String field,
                                              String term)
        Makes a new SpanTermQuery (with additional asserts).
      • spanOrQuery

        public static SpanQuery spanOrQuery​(String field,
                                            String... terms)
        Makes a new SpanOrQuery (with additional asserts) from the provided terms.
      • spanOrQuery

        public static SpanQuery spanOrQuery​(SpanQuery... subqueries)
        Makes a new SpanOrQuery (with additional asserts).
      • spanNotQuery

        public static SpanQuery spanNotQuery​(SpanQuery include,
                                             SpanQuery exclude)
        Makes a new SpanNotQuery (with additional asserts).
      • spanNotQuery

        public static SpanQuery spanNotQuery​(SpanQuery include,
                                             SpanQuery exclude,
                                             int pre,
                                             int post)
        Makes a new SpanNotQuery (with additional asserts).
      • spanFirstQuery

        public static SpanQuery spanFirstQuery​(SpanQuery query,
                                               int end)
        Makes a new SpanFirstQuery (with additional asserts).
      • spanPositionRangeQuery

        public static SpanQuery spanPositionRangeQuery​(SpanQuery query,
                                                       int start,
                                                       int end)
        Makes a new SpanPositionRangeQuery (with additional asserts).
      • spanContainingQuery

        public static SpanQuery spanContainingQuery​(SpanQuery big,
                                                    SpanQuery little)
        Makes a new SpanContainingQuery (with additional asserts).
      • spanWithinQuery

        public static SpanQuery spanWithinQuery​(SpanQuery big,
                                                SpanQuery little)
        Makes a new SpanWithinQuery (with additional asserts).
      • spanNearOrderedQuery

        public static SpanQuery spanNearOrderedQuery​(String field,
                                                     int slop,
                                                     String... terms)
        Makes a new ordered SpanNearQuery (with additional asserts) from the provided terms
      • spanNearOrderedQuery

        public static SpanQuery spanNearOrderedQuery​(int slop,
                                                     SpanQuery... subqueries)
        Makes a new ordered SpanNearQuery (with additional asserts)
      • spanNearUnorderedQuery

        public static SpanQuery spanNearUnorderedQuery​(String field,
                                                       int slop,
                                                       String... terms)
        Makes a new unordered SpanNearQuery (with additional asserts) from the provided terms
      • spanNearUnorderedQuery

        public static SpanQuery spanNearUnorderedQuery​(int slop,
                                                       SpanQuery... subqueries)
        Makes a new unordered SpanNearQuery (with additional asserts)
      • assertNext

        public static void assertNext​(Spans spans,
                                      int doc,
                                      int start,
                                      int end)
                               throws IOException
        Assert the next iteration from spans is a match from start to end in doc.
        Throws:
        IOException
      • assertFinished

        public static void assertFinished​(Spans spans)
                                   throws Exception
        Assert that spans is exhausted.
        Throws:
        Exception