Package org.apache.solr.search
Class QueryUtils
- java.lang.Object
-
- org.apache.solr.search.QueryUtils
-
public class QueryUtils extends Object
-
-
Constructor Summary
Constructors Constructor Description QueryUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.apache.lucene.search.BooleanQuerybuild(org.apache.lucene.search.BooleanQuery.Builder builder, QParser parser)static org.apache.lucene.search.QuerycombineQueryAndFilter(org.apache.lucene.search.Query scoreQuery, org.apache.lucene.search.Query filterQuery)Combines a scoring query with a non-scoring (filter) query.static org.apache.lucene.search.QueryfixNegativeQuery(org.apache.lucene.search.Query q)Fixes a negative query by adding a MatchAllDocs query clause.static org.apache.lucene.search.QuerygetAbs(org.apache.lucene.search.Query q)Returns the original query if it was already a positive query, otherwise return the negative of the query (i.e., a positive query).static booleanisNegative(org.apache.lucene.search.Query q)return true if this query has no positive componentsstatic org.apache.lucene.search.QuerymakeQueryable(org.apache.lucene.search.Query q)Makes negative queries suitable for querying by lucene.
-
-
-
Method Detail
-
isNegative
public static boolean isNegative(org.apache.lucene.search.Query q)
return true if this query has no positive components
-
getAbs
public static org.apache.lucene.search.Query getAbs(org.apache.lucene.search.Query q)
Returns the original query if it was already a positive query, otherwise return the negative of the query (i.e., a positive query).Example: both id:10 and id:-10 will return id:10
The caller can tell the sign of the original by a reference comparison between the original and returned query.
- Parameters:
q- Query to create the absolute version of- Returns:
- Absolute version of the Query
-
makeQueryable
public static org.apache.lucene.search.Query makeQueryable(org.apache.lucene.search.Query q)
Makes negative queries suitable for querying by lucene.
-
fixNegativeQuery
public static org.apache.lucene.search.Query fixNegativeQuery(org.apache.lucene.search.Query q)
Fixes a negative query by adding a MatchAllDocs query clause. The query passed in *must* be a negative query.
-
build
public static org.apache.lucene.search.BooleanQuery build(org.apache.lucene.search.BooleanQuery.Builder builder, QParser parser)- WARNING: This API is experimental and might change in incompatible ways in the next release.
- throw exception if max boolean clauses are exceeded
-
combineQueryAndFilter
public static org.apache.lucene.search.Query combineQueryAndFilter(org.apache.lucene.search.Query scoreQuery, org.apache.lucene.search.Query filterQuery)Combines a scoring query with a non-scoring (filter) query. If both parameters are null then return aMatchAllDocsQuery. If onlyscoreQueryis present then return it. If onlyfilterQueryis present then return it wrapped with constant scoring. If neither are null then we combine with a BooleanQuery.
-
-