public class QueryUtils extends Object
Constructor and Description |
---|
QueryUtils() |
Modifier and Type | Method and Description |
---|---|
static BooleanQuery |
build(BooleanQuery.Builder builder,
QParser parser) |
static Query |
combineQueryAndFilter(Query scoreQuery,
Query filterQuery)
Combines a scoring query with a non-scoring (filter) query.
|
static Query |
fixNegativeQuery(Query q)
Fixes a negative query by adding a MatchAllDocs query clause.
|
static Query |
getAbs(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 boolean |
isNegative(Query q)
return true if this query has no positive components
|
static Query |
makeQueryable(Query q)
Makes negative queries suitable for querying by
lucene.
|
public static boolean isNegative(Query q)
public static Query getAbs(Query q)
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.
q
- Query to create the absolute version ofpublic static Query makeQueryable(Query q)
public static Query fixNegativeQuery(Query q)
public static BooleanQuery build(BooleanQuery.Builder builder, QParser parser)
public static Query combineQueryAndFilter(Query scoreQuery, Query filterQuery)
MatchAllDocsQuery
.
If only scoreQuery
is present then return it.
If only filterQuery
is present then return it wrapped with constant scoring.
If neither are null then we combine with a BooleanQuery.Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.