org.apache.lucene.search

## Class QueryUtils

- java.lang.Object
- - org.apache.lucene.search.QueryUtils

-     public class QueryUtils
      extends Object

  Utility class for sanity-checking queries.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `QueryUtils()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `check(Query q)` Check the types of things query objects should be able to do.
    `static void` | `check(Random random, Query q1, IndexSearcher s)` Various query sanity checks on a searcher, some checks are only done for instanceof IndexSearcher.
    `static void` | `check(Random random, Query q1, IndexSearcher s, boolean wrap)`
    `static void` | `checkBulkScorerSkipTo(Random r, Query query, IndexSearcher searcher)` Check that the scorer and bulk scorer advance consistently.
    `static void` | `checkEqual(Query q1, Query q2)`
    `static void` | `checkExplanations(Query q, IndexSearcher s)` deep check that explanations of a query 'score' correctly
    `static void` | `checkFirstSkipTo(Query q, IndexSearcher s)` check that first skip on just created scorers always goes to the right doc
    `static void` | `checkHashEquals(Query q)` check very basic hashCode and equals
    `static void` | `checkSkipTo(Query q, IndexSearcher s)` alternate scorer advance(),advance(),next(),next(),advance(),advance(), etc and ensure a hitcollector receives same docs and scores
    `static void` | `checkUnequal(Query q1, Query q2)`
    `static IndexSearcher` | `wrapUnderlyingReader(Random random, IndexSearcher s, int edge)` Given an IndexSearcher, returns a new IndexSearcher whose IndexReader is a MultiReader containing the Reader of the original IndexSearcher, as well as several "empty" IndexReaders -- some of which will have deleted documents in them.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### QueryUtils

          public QueryUtils()

  - ### Method Detail

    - #### check

          public static void check(Query q)

      Check the types of things query objects should be able to do.

    - #### checkHashEquals

          public static void checkHashEquals(Query q)

      check very basic hashCode and equals

    - #### checkEqual

          public static void checkEqual(Query q1,
                                        Query q2)

    - #### checkUnequal

          public static void checkUnequal(Query q1,
                                          Query q2)

    - #### checkExplanations

          public static void checkExplanations(Query q,
                                               IndexSearcher s)
                                        throws IOException

      deep check that explanations of a query 'score' correctly
      Throws:
        `IOException`

    - #### check

          public static void check(Random random,
                                   Query q1,
                                   IndexSearcher s)

      Various query sanity checks on a searcher, some checks are only done for instanceof IndexSearcher.
      See Also:
        `check(Query)`, `checkFirstSkipTo(org.apache.lucene.search.Query, org.apache.lucene.search.IndexSearcher)`, `checkSkipTo(org.apache.lucene.search.Query, org.apache.lucene.search.IndexSearcher)`, `checkExplanations(org.apache.lucene.search.Query, org.apache.lucene.search.IndexSearcher)`, `checkEqual(org.apache.lucene.search.Query, org.apache.lucene.search.Query)`, `CheckHits.checkMatches(Query, IndexSearcher)`

    - #### check

          public static void check(Random random,
                                   Query q1,
                                   IndexSearcher s,
                                   boolean wrap)

    - #### wrapUnderlyingReader

          public static IndexSearcher wrapUnderlyingReader(Random random,
                                                           IndexSearcher s,
                                                           int edge)
                                                    throws IOException

      Given an IndexSearcher, returns a new IndexSearcher whose IndexReader is a MultiReader containing the Reader of the original IndexSearcher, as well as several "empty" IndexReaders -- some of which will have deleted documents in them. This new IndexSearcher should behave exactly the same as the original IndexSearcher.
      Parameters:
        `s` - the searcher to wrap
        `edge` - if negative, s will be the first sub; if 0, s will be in the middle, if positive s will be the last sub
      Throws:
        `IOException`

    - #### checkSkipTo

          public static void checkSkipTo(Query q,
                                         IndexSearcher s)
                                  throws IOException

      alternate scorer advance(),advance(),next(),next(),advance(),advance(), etc and ensure a hitcollector receives same docs and scores
      Throws:
        `IOException`

    - #### checkFirstSkipTo

          public static void checkFirstSkipTo(Query q,
                                              IndexSearcher s)
                                       throws IOException

      check that first skip on just created scorers always goes to the right doc
      Throws:
        `IOException`

    - #### checkBulkScorerSkipTo

          public static void checkBulkScorerSkipTo(Random r,
                                                   Query query,
                                                   IndexSearcher searcher)
                                            throws IOException

      Check that the scorer and bulk scorer advance consistently.
      Throws:
        `IOException`

Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.