expose boolean and Object as values for TermQueryBuilder and FieldQueryBuilder

This commit is contained in:
kimchy 2010-11-06 01:04:14 +02:00
parent 129b9a3938
commit 87efccf677
3 changed files with 72 additions and 6 deletions

View File

@ -129,7 +129,19 @@ public class FieldQueryBuilder extends BaseQueryBuilder {
* @param name The name of the field
* @param query The query string
*/
private FieldQueryBuilder(String name, Object query) {
public FieldQueryBuilder(String name, boolean query) {
this(name, (Object) query);
}
/**
* A query that executes the query string against a field. It is a simplified
* version of {@link QueryStringQueryBuilder} that simply runs against
* a single field.
*
* @param name The name of the field
* @param query The query string
*/
public FieldQueryBuilder(String name, Object query) {
this.name = name;
this.query = query;
}

View File

@ -83,13 +83,13 @@ public abstract class QueryBuilders {
}
/**
* A Query that matches documents using fuzzy query.
* A Query that matches documents containing a term.
*
* @param name The name of the field
* @param value The value of the term
*/
public static FuzzyQueryBuilder fuzzyQuery(String name, String value) {
return new FuzzyQueryBuilder(name, value);
public static TermQueryBuilder termQuery(String name, double value) {
return new TermQueryBuilder(name, value);
}
/**
@ -98,10 +98,30 @@ public abstract class QueryBuilders {
* @param name The name of the field
* @param value The value of the term
*/
public static TermQueryBuilder termQuery(String name, double value) {
public static TermQueryBuilder termQuery(String name, boolean value) {
return new TermQueryBuilder(name, value);
}
/**
* A Query that matches documents containing a term.
*
* @param name The name of the field
* @param value The value of the term
*/
public static TermQueryBuilder termQuery(String name, Object value) {
return new TermQueryBuilder(name, value);
}
/**
* A Query that matches documents using fuzzy query.
*
* @param name The name of the field
* @param value The value of the term
*/
public static FuzzyQueryBuilder fuzzyQuery(String name, String value) {
return new FuzzyQueryBuilder(name, value);
}
/**
* A query that executes the query string against a field. It is a simplified
* version of {@link QueryStringQueryBuilder} that simply runs against
@ -161,6 +181,30 @@ public abstract class QueryBuilders {
return new FieldQueryBuilder(name, query);
}
/**
* A query that executes the query string against a field. It is a simplified
* version of {@link QueryStringQueryBuilder} that simply runs against
* a single field.
*
* @param name The name of the field
* @param query The query string
*/
public static FieldQueryBuilder fieldQuery(String name, boolean query) {
return new FieldQueryBuilder(name, query);
}
/**
* A query that executes the query string against a field. It is a simplified
* version of {@link QueryStringQueryBuilder} that simply runs against
* a single field.
*
* @param name The name of the field
* @param query The query string
*/
public static FieldQueryBuilder fieldQuery(String name, Object query) {
return new FieldQueryBuilder(name, query);
}
/**
* A Query that matches documents containing terms with a specified prefix.
*

View File

@ -92,7 +92,17 @@ public class TermQueryBuilder extends BaseQueryBuilder {
* @param name The name of the field
* @param value The value of the term
*/
private TermQueryBuilder(String name, Object value) {
public TermQueryBuilder(String name, boolean value) {
this(name, (Object) value);
}
/**
* Constructs a new term query.
*
* @param name The name of the field
* @param value The value of the term
*/
public TermQueryBuilder(String name, Object value) {
this.name = name;
this.value = value;
}