|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface CompassQueryBuilder
The query builder is used to construct CompassQueryBuilder.ToCompassQuery programmatically.
Simple queries, like le(String,Object), will generate a CompassQueryBuilder.ToCompassQuery.
More complex ones, will return their respective builder to continue and bulid them (like
multiPhrase(String)). Combining CompassQueryBuilder.ToCompassQuerys can be done using
the bool() operation.
An example of building a query using the query builder:
CompassQueryBuilder queryBuilder = session.queryBuilder();
queryBuilder.bool().addMust(queryBuilder.term("name", "jack")).addMust(queryBuilder.lt("birthdate", "19500101"))
.toQuery().hits();
| Nested Class Summary | |
|---|---|
static interface |
CompassQueryBuilder.CompassBooleanQueryBuilder
A boolean query builder. |
static interface |
CompassQueryBuilder.CompassMoreLikeThisQuery
A more like this query builder (maps to Lucene MoreLikeThis feature withing
the contrib queries package). |
static interface |
CompassQueryBuilder.CompassMultiPhraseQueryBuilder
A query builder that constructs a phrase query. |
static interface |
CompassQueryBuilder.CompassMultiPropertyQueryStringBuilder
Parses the query string into terms, which all of them are used against the given resource property name / meta-data. |
static interface |
CompassQueryBuilder.CompassQuerySpanNearBuilder
A span near query builder. |
static interface |
CompassQueryBuilder.CompassQuerySpanOrBuilder
Creates a span or query builder. |
static interface |
CompassQueryBuilder.CompassQueryStringBuilder
A query builder used to construct a query from a query string (i.e. |
static interface |
CompassQueryBuilder.ToCompassQuery
A general interface for internal builders that will create a CompassQuery. |
| Method Summary | |
|---|---|
CompassQueryBuilder |
addAliasQueryIfNeeded(boolean addAliasQueryIfNeeded)
Should the query builder wrap automatically any query that has dot path notation (such as alias.property) with specific narrowing to match the given alias. |
CompassQuery |
alias(String aliasValue)
Returns a query that exactly match the given alias. |
CompassQuery |
between(String name,
Object low,
Object high,
boolean inclusive)
Creates a query where the resource property is between the given values. |
CompassQuery |
between(String name,
Object low,
Object high,
boolean inclusive,
boolean constantScore)
Creates a query where the resource property is between the given values. |
CompassQueryBuilder.CompassBooleanQueryBuilder |
bool()
Constructs a boolean query builder. |
CompassQueryBuilder.CompassBooleanQueryBuilder |
bool(boolean disableCoord)
Constructs a boolean query builder, with coord disabled. |
CompassQueryBuilder |
convertOnlyWithDotPath(boolean convertOnlyWithDotPath)
Should Compass use a converter for value passed even if there is no specific direct dot path notation to it. |
CompassQuery |
fuzzy(String name,
String value)
Creates a fuzzy query for the given resource property and the value. |
CompassQuery |
fuzzy(String name,
String value,
float minimumSimilarity)
Creates a fuzzy query for the given resource property and the value. |
CompassQuery |
fuzzy(String name,
String value,
float minimumSimilarity,
int prefixLength)
Creates a fuzzy query for the given resource property and the value. |
CompassQuery |
ge(String name,
Object value)
Creates a query where the resource property is greater or equal (>=) to the given value. |
CompassQuery |
gt(String name,
Object value)
Creates a query where the resource property is greater than (>) to the given value. |
CompassQuery |
le(String name,
Object value)
Creates a query where the resource property is less or equal (<=) to the given value. |
CompassQuery |
lt(String name,
Object value)
Creates a query where the resource property is less than (<) the given value. |
CompassQuery |
matchAll()
Creates a query that match all documents. |
CompassQueryBuilder.CompassMoreLikeThisQuery |
moreLikeThis(Reader reader)
Constructs a more like this query to find hits that are similar to the give text represented by the reader. |
CompassQueryBuilder.CompassMoreLikeThisQuery |
moreLikeThis(String alias,
Serializable id)
Constructs a more like this query. |
CompassQueryBuilder.CompassMultiPhraseQueryBuilder |
multiPhrase(String name)
Constructs a multi phrase query builder for the given resource property / meta-data name. |
CompassQueryBuilder.CompassMultiPropertyQueryStringBuilder |
multiPropertyQueryString(String queryString)
Constructs a multi property query string builder, allowing to execute query strings against several resource property names. |
CompassQuery |
polyAlias(String aliasValue)
Returns a query that match the given alias or any extedning aliases. |
CompassQuery |
prefix(String name,
String prefix)
Creates a query where the resource property values starts with the given prefix. |
CompassQueryBuilder.CompassQueryStringBuilder |
queryString(String queryString)
Constructs a query string query builder. |
CompassQuery.CompassSpanQuery |
spanEq(String name,
Object value)
Creates a span query where the resource property must match the given value. |
CompassQuery.CompassSpanQuery |
spanFirst(CompassQuery.CompassSpanQuery spanQuery,
int end)
Creates a span query. |
CompassQuery.CompassSpanQuery |
spanFirst(String name,
Object value,
int end)
Creates a span query where the span occur within the first end positions. |
CompassQueryBuilder.CompassQuerySpanNearBuilder |
spanNear(String name)
Constructs a span near query builder. |
CompassQuery.CompassSpanQuery |
spanNot(CompassQuery.CompassSpanQuery include,
CompassQuery.CompassSpanQuery exclude)
Creates a span query that excludes matches where one CompassQuery.CompassSpanQuery overlaps
with another. |
CompassQueryBuilder.CompassQuerySpanOrBuilder |
spanOr()
Constructs a span or query builder. |
CompassQuery |
term(String name,
Object value)
Creates a query where the resource property must have the given value. |
CompassQuery |
wildcard(String name,
String wildcard)
Creates a query where the resource property values match the given wildcard. |
| Method Detail |
|---|
CompassQueryBuilder convertOnlyWithDotPath(boolean convertOnlyWithDotPath)
false.
ResourcePropertyLookup.setConvertOnlyWithDotPath(boolean)CompassQueryBuilder addAliasQueryIfNeeded(boolean addAliasQueryIfNeeded)
alias.property) with specific narrowing to match the given alias. Default to
true.
CompassQueryBuilder.CompassBooleanQueryBuilder bool()
CompassQueryBuilder.CompassBooleanQueryBuilder bool(boolean disableCoord)
CompassQueryBuilder.CompassMultiPhraseQueryBuilder multiPhrase(String name)
name - The name of the resource property / meta-data.
CompassQueryBuilder.CompassQueryStringBuilder queryString(String queryString)
queryString - The query string (i.e. +jack +london).
CompassQueryBuilder.CompassMultiPropertyQueryStringBuilder multiPropertyQueryString(String queryString)
queryString - The query string (i.e. +jack +london)
CompassQuery alias(String aliasValue)
Note, this will not narrow down the search to specific sub indxes.
In order to do that, please use CompassQuery.setAliases(String[]).
aliasValue - The alias value to match to.
CompassQuery polyAlias(String aliasValue)
Note, this will not narrow down the search to specific sub indxes.
In order to do that, please use CompassQuery.setAliases(String[]).
aliasValue - The alias value to match to or any extending aliases.
CompassQuery term(String name,
Object value)
Creates a query where the resource property must have the given value.
Note, that the value itself will not be analyzed, but the text that was
indexed might have been (if indexed). The search is case
sensative.
The name can either be the actual resource property or meta-data value, or the path to the given resource property (alias.rProperty), or the class property (alias.cProperty) or the path to the meta-data (alias.cProperty.metaData)
name - The resource property namevalue - The value that must match
CompassQuery matchAll()
CompassQuery between(String name,
Object low,
Object high,
boolean inclusive,
boolean constantScore)
Creates a query where the resource property is between the given values.
The name can either be the actual resource property or meta-data value, or the path to the given resource property (alias.rProperty), or the class property (alias.cProperty) or the path to the meta-data (alias.cProperty.metaData)
name - The resource property namelow - The low value limithigh - The high value limitinclusive - If the values are inclusive or exclusive.constantScore - If the query will affect the score of the results. With all other range queries
it will default to true.
CompassQuery between(String name,
Object low,
Object high,
boolean inclusive)
Creates a query where the resource property is between the given values.
The name can either be the actual resource property or meta-data value, or the path to the given resource property (alias.rProperty), or the class property (alias.cProperty) or the path to the meta-data (alias.cProperty.metaData)
name - The resource property namelow - The low value limithigh - The high value limitinclusive - If the values are inclusive or exclusive.
CompassQuery lt(String name,
Object value)
Creates a query where the resource property is less than (<) the given value.
The name can either be the actual resource property or meta-data value, or the path to the given resource property (alias.rProperty), or the class property (alias.cProperty) or the path to the meta-data (alias.cProperty.metaData)
name - The resource property namevalue - The high limit value
CompassQuery le(String name,
Object value)
Creates a query where the resource property is less or equal (<=) to the given value.
The name can either be the actual resource property or meta-data value, or the path to the given resource property (alias.rProperty), or the class property (alias.cProperty) or the path to the meta-data (alias.cProperty.metaData)
name - The resource property namevalue - The high limit value
CompassQuery gt(String name,
Object value)
Creates a query where the resource property is greater than (>) to the given value.
The name can either be the actual resource property or meta-data value, or the path to the given resource property (alias.rProperty), or the class property (alias.cProperty) or the path to the meta-data (alias.cProperty.metaData)
name - The resource property namevalue - The low limit value
CompassQuery ge(String name,
Object value)
Creates a query where the resource property is greater or equal (>=) to the given value.
The name can either be the actual resource property or meta-data value, or the path to the given resource property (alias.rProperty), or the class property (alias.cProperty) or the path to the meta-data (alias.cProperty.metaData)
name - The resource property namevalue - The low limit value
CompassQuery prefix(String name,
String prefix)
Creates a query where the resource property values starts with the given prefix.
The name can either be the actual resource property or meta-data value, or the path to the given resource property (alias.rProperty), or the class property (alias.cProperty) or the path to the meta-data (alias.cProperty.metaData)
name - the resource property nameprefix - The prefix value
CompassQuery wildcard(String name,
String wildcard)
*, which matches any
character sequence (including the empty one), and ?,
which matches any single character. Note this query can be slow, as it
needs to iterate over many terms. In order to prevent extremely slow
WildcardQueries, a Wildcard term should not start with one of the
wildcards * or ?.
name - The namewildcard - The wildcard expression
CompassQuery fuzzy(String name,
String value)
Creates a fuzzy query for the given resource property and the value. The similiarity measurement is based on the Levenshtein (edit distance) algorithm. The minimumSimilarity defaults to 0.5 and prefixLength defaults to 0.
The name can either be the actual resource property or meta-data value, or the path to the given resource property (alias.rProperty), or the class property (alias.cProperty) or the path to the meta-data (alias.cProperty.metaData)
name - The namevalue - The value
CompassQuery fuzzy(String name,
String value,
float minimumSimilarity)
Creates a fuzzy query for the given resource property and the value. The similiarity measurement is based on the Levenshtein (edit distance) algorithm. The prefixLength defaults to 0.
The name can either be the actual resource property or meta-data value, or the path to the given resource property (alias.rProperty), or the class property (alias.cProperty) or the path to the meta-data (alias.cProperty.metaData)
name - The namevalue - The valueminimumSimilarity - The minimum similarity, a value between 0.0 and 1.0
CompassQuery fuzzy(String name,
String value,
float minimumSimilarity,
int prefixLength)
Creates a fuzzy query for the given resource property and the value. The similiarity measurement is based on the Levenshtein (edit distance) algorithm.
The name can either be the actual resource property or meta-data value, or the path to the given resource property (alias.rProperty), or the class property (alias.cProperty) or the path to the meta-data (alias.cProperty.metaData)
name - The namevalue - The valueminimumSimilarity - The minimum similarity, a value between 0.0 and 1.0prefixLength - The length of common (non-fuzzy) prefix
CompassQuery.CompassSpanQuery spanEq(String name,
Object value)
Creates a span query where the resource property must match the given value.
The name can either be the actual resource property or meta-data value, or the path to the given resource property (alias.rProperty), or the class property (alias.cProperty) or the path to the meta-data (alias.cProperty.metaData)
name - The namevalue - The value
CompassQuery.CompassSpanQuery spanFirst(String name,
Object value,
int end)
Creates a span query where the span occur within the first
end positions.
The name can either be the actual resource property or meta-data value, or the path to the given resource property (alias.rProperty), or the class property (alias.cProperty) or the path to the meta-data (alias.cProperty.metaData)
name - The namevalue - The valueend - The limit on the position from the start.
CompassQuery.CompassSpanQuery spanFirst(CompassQuery.CompassSpanQuery spanQuery,
int end)
Creates a span query.
end - The limit on the position from the start.
CompassQueryBuilder.CompassQuerySpanNearBuilder spanNear(String name)
Constructs a span near query builder.
The name can either be the actual resource property or meta-data value, or the path to the given resource property (alias.rProperty), or the class property (alias.cProperty) or the path to the meta-data (alias.cProperty.metaData)
name - The name
CompassQuery.CompassSpanQuery spanNot(CompassQuery.CompassSpanQuery include,
CompassQuery.CompassSpanQuery exclude)
Creates a span query that excludes matches where one
CompassQuery.CompassSpanQuery overlaps
with another.
Construct a span query matching spans from include which
have no overlap with spans from exclude.
include - The span query to include.exclude - The span query to exclude.
CompassQueryBuilder.CompassQuerySpanOrBuilder spanOr()
CompassQueryBuilder.CompassMoreLikeThisQuery moreLikeThis(String alias,
Serializable id)
CompassQueryBuilder.CompassMoreLikeThisQuery moreLikeThis(Reader reader)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||