Class QueryMatchers


  • public class QueryMatchers
    extends Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.hamcrest.Matcher<org.apache.lucene.search.BooleanClause> booleanClause​(org.hamcrest.Matcher<? extends org.apache.lucene.search.Query> query, org.apache.lucene.search.BooleanClause.Occur occur)  
      static org.hamcrest.Matcher<org.apache.lucene.search.Query> booleanQuery​(org.hamcrest.Matcher<org.apache.lucene.search.Query> query)  
      static org.hamcrest.Matcher<org.apache.lucene.search.Query> booleanQuery​(org.hamcrest.Matcher<org.apache.lucene.search.Query> q1, org.apache.lucene.search.BooleanClause.Occur occur)  
      static org.hamcrest.Matcher<org.apache.lucene.search.Query> booleanQuery​(org.hamcrest.Matcher<org.apache.lucene.search.Query> c1, org.hamcrest.Matcher<org.apache.lucene.search.Query> c2)  
      static org.hamcrest.Matcher<org.apache.lucene.search.Query> booleanQuery​(org.hamcrest.Matcher<org.apache.lucene.search.Query> q1, org.hamcrest.Matcher<org.apache.lucene.search.Query> q2, org.apache.lucene.search.BooleanClause.Occur occur)  
      static org.hamcrest.Matcher<org.apache.lucene.search.Query> booleanQuery​(org.hamcrest.Matcher<org.apache.lucene.search.Query> c1, org.hamcrest.Matcher<org.apache.lucene.search.Query> c2, org.hamcrest.Matcher<org.apache.lucene.search.Query> c3)  
      static org.hamcrest.Matcher<org.apache.lucene.search.Query> booleanQuery​(org.hamcrest.Matcher<org.apache.lucene.search.Query> c1, org.hamcrest.Matcher<org.apache.lucene.search.Query> c2, org.hamcrest.Matcher<org.apache.lucene.search.Query> c3, org.hamcrest.Matcher<org.apache.lucene.search.Query> c4)  
      static org.hamcrest.Matcher<org.apache.lucene.search.Query> boosted​(String field, String text, float boost)  
      static org.hamcrest.Matcher<org.apache.lucene.search.Query> boosted​(org.hamcrest.Matcher<? extends org.apache.lucene.search.Query> query, float boost)  
      static org.hamcrest.Matcher<org.apache.lucene.search.Query> disjunctionOf​(org.hamcrest.Matcher<org.apache.lucene.search.Query> q1)  
      static org.hamcrest.Matcher<org.apache.lucene.search.Query> disjunctionOf​(org.hamcrest.Matcher<org.apache.lucene.search.Query> q1, org.hamcrest.Matcher<org.apache.lucene.search.Query> q2)  
      static org.hamcrest.Matcher<org.apache.lucene.search.Query> disjunctionOf​(org.hamcrest.Matcher<org.apache.lucene.search.Query> q1, org.hamcrest.Matcher<org.apache.lucene.search.Query> q2, org.hamcrest.Matcher<org.apache.lucene.search.Query> q3)  
      static org.hamcrest.Matcher<org.apache.lucene.search.Query> disjunctionOf​(org.hamcrest.Matcher<org.apache.lucene.search.Query> q1, org.hamcrest.Matcher<org.apache.lucene.search.Query> q2, org.hamcrest.Matcher<org.apache.lucene.search.Query> q3, org.hamcrest.Matcher<org.apache.lucene.search.Query> q4)  
      static org.hamcrest.Matcher<org.apache.lucene.search.Query> phraseQuery​(String field, String terms)
      Create a phrase query matcher with a whitespace delimited sequence of terms
      static org.hamcrest.Matcher<org.apache.lucene.search.Query> stringQuery​(String query)
      Matches is a Query object's toString result is equal to this query string.
      static org.hamcrest.Matcher<org.apache.lucene.search.Query> termQuery​(String field, String text)  
    • Method Detail

      • stringQuery

        public static org.hamcrest.Matcher<org.apache.lucene.search.Query> stringQuery​(String query)
        Matches is a Query object's toString result is equal to this query string. A useful shortcut when constructing complex queries with deterministic string repr

        Note: Do not use this in place of DisjunctionMaxQuery, but safe to use for the disjunct clauses

        Parameters:
        query - the query string to match against
      • termQuery

        public static org.hamcrest.Matcher<org.apache.lucene.search.Query> termQuery​(String field,
                                                                                     String text)
      • boosted

        public static org.hamcrest.Matcher<org.apache.lucene.search.Query> boosted​(String field,
                                                                                   String text,
                                                                                   float boost)
      • boosted

        public static org.hamcrest.Matcher<org.apache.lucene.search.Query> boosted​(org.hamcrest.Matcher<? extends org.apache.lucene.search.Query> query,
                                                                                   float boost)
      • phraseQuery

        public static org.hamcrest.Matcher<org.apache.lucene.search.Query> phraseQuery​(String field,
                                                                                       String terms)
        Create a phrase query matcher with a whitespace delimited sequence of terms
        Parameters:
        field - the field the phrase query should match against
        terms - a whitespace delimited set of terms that should
      • booleanClause

        public static org.hamcrest.Matcher<org.apache.lucene.search.BooleanClause> booleanClause​(org.hamcrest.Matcher<? extends org.apache.lucene.search.Query> query,
                                                                                                 org.apache.lucene.search.BooleanClause.Occur occur)
      • booleanQuery

        public static org.hamcrest.Matcher<org.apache.lucene.search.Query> booleanQuery​(org.hamcrest.Matcher<org.apache.lucene.search.Query> q1,
                                                                                        org.apache.lucene.search.BooleanClause.Occur occur)
      • booleanQuery

        public static org.hamcrest.Matcher<org.apache.lucene.search.Query> booleanQuery​(org.hamcrest.Matcher<org.apache.lucene.search.Query> q1,
                                                                                        org.hamcrest.Matcher<org.apache.lucene.search.Query> q2,
                                                                                        org.apache.lucene.search.BooleanClause.Occur occur)
      • booleanQuery

        public static org.hamcrest.Matcher<org.apache.lucene.search.Query> booleanQuery​(org.hamcrest.Matcher<org.apache.lucene.search.Query> query)
      • booleanQuery

        public static org.hamcrest.Matcher<org.apache.lucene.search.Query> booleanQuery​(org.hamcrest.Matcher<org.apache.lucene.search.Query> c1,
                                                                                        org.hamcrest.Matcher<org.apache.lucene.search.Query> c2)
      • booleanQuery

        public static org.hamcrest.Matcher<org.apache.lucene.search.Query> booleanQuery​(org.hamcrest.Matcher<org.apache.lucene.search.Query> c1,
                                                                                        org.hamcrest.Matcher<org.apache.lucene.search.Query> c2,
                                                                                        org.hamcrest.Matcher<org.apache.lucene.search.Query> c3)
      • booleanQuery

        public static org.hamcrest.Matcher<org.apache.lucene.search.Query> booleanQuery​(org.hamcrest.Matcher<org.apache.lucene.search.Query> c1,
                                                                                        org.hamcrest.Matcher<org.apache.lucene.search.Query> c2,
                                                                                        org.hamcrest.Matcher<org.apache.lucene.search.Query> c3,
                                                                                        org.hamcrest.Matcher<org.apache.lucene.search.Query> c4)
      • disjunctionOf

        public static org.hamcrest.Matcher<org.apache.lucene.search.Query> disjunctionOf​(org.hamcrest.Matcher<org.apache.lucene.search.Query> q1)
      • disjunctionOf

        public static org.hamcrest.Matcher<org.apache.lucene.search.Query> disjunctionOf​(org.hamcrest.Matcher<org.apache.lucene.search.Query> q1,
                                                                                         org.hamcrest.Matcher<org.apache.lucene.search.Query> q2)
      • disjunctionOf

        public static org.hamcrest.Matcher<org.apache.lucene.search.Query> disjunctionOf​(org.hamcrest.Matcher<org.apache.lucene.search.Query> q1,
                                                                                         org.hamcrest.Matcher<org.apache.lucene.search.Query> q2,
                                                                                         org.hamcrest.Matcher<org.apache.lucene.search.Query> q3)
      • disjunctionOf

        public static org.hamcrest.Matcher<org.apache.lucene.search.Query> disjunctionOf​(org.hamcrest.Matcher<org.apache.lucene.search.Query> q1,
                                                                                         org.hamcrest.Matcher<org.apache.lucene.search.Query> q2,
                                                                                         org.hamcrest.Matcher<org.apache.lucene.search.Query> q3,
                                                                                         org.hamcrest.Matcher<org.apache.lucene.search.Query> q4)