Spring Data Elasticsearch

org.springframework.data.elasticsearch.core.query
Class Criteria

java.lang.Object
  extended by org.springframework.data.elasticsearch.core.query.Criteria

public class Criteria
extends Object

Criteria is the central class when constructing queries. It follows more or less a fluent API style, which allows to easily chain together multiple criteria.


Nested Class Summary
static class Criteria.CriteriaEntry
           
static class Criteria.OperationKey
           
 
Field Summary
static String CRITERIA_VALUE_SEPERATOR
           
static String WILDCARD
           
 
Constructor Summary
  Criteria()
           
  Criteria(Field field)
          Creates a new Criteria for the given field
protected Criteria(List<Criteria> criteriaChain, Field field)
           
protected Criteria(List<Criteria> criteriaChain, String fieldname)
           
  Criteria(String fieldname)
          Creates a new CriterSimpleFieldia for the Filed with provided name
 
Method Summary
 Criteria and(Criteria... criterias)
          Chain using AND
 Criteria and(Criteria criteria)
          Chain using AND
 Criteria and(Field field)
          Chain using AND
 Criteria and(String fieldName)
          Chain using AND
 Criteria between(Object lowerBound, Object upperBound)
          Crates new CriteriaEntry for RANGE [lowerBound TO upperBound]
 Criteria boost(float boost)
          Boost positive hit with given factor. eg. ^2.3
 Criteria contains(String s)
          Crates new CriteriaEntry with leading and trailing wildcards
NOTE: mind your schema as leading wildcards may not be supported and/or execution might be slow.
 Criteria endsWith(String s)
          Crates new CriteriaEntry with leading wildcard
NOTE: mind your schema and execution times as leading wildcards may not be supported.
 Criteria expression(String s)
          Crates new CriteriaEntry allowing native elasticsearch expressions
 Criteria fuzzy(String s)
          Crates new CriteriaEntry with trailing ~
 float getBoost()
           
 String getConjunctionOperator()
          Conjunction to be used with this criteria (AND | OR)
 List<Criteria> getCriteriaChain()
           
 Set<Criteria.CriteriaEntry> getCriteriaEntries()
           
 Field getField()
          Field targeted by this Criteria
 Criteria greaterThanEqual(Object lowerBound)
          Crates new CriteriaEntry for RANGE [lowerBound TO *]
 Criteria in(Iterable<?> values)
          Crates new CriteriaEntry for multiple values (arg0 arg1 arg2 ...)
 Criteria in(Object... values)
          Crates new CriteriaEntry for multiple values (arg0 arg1 arg2 ...)
 Criteria is(Object o)
          Crates new CriteriaEntry without any wildcards
 boolean isAnd()
           
 boolean isNegating()
           
 boolean isOr()
           
 Criteria lessThanEqual(Object upperBound)
          Crates new CriteriaEntry for RANGE [* TO upperBound]
 Criteria not()
          Crates new CriteriaEntry with trailing -
 Criteria or(Criteria criteria)
          Chain using OR
 Criteria or(Field field)
          Chain using OR
 Criteria or(String fieldName)
          Chain using OR
 Criteria startsWith(String s)
          Crates new CriteriaEntry with trailing wildcard
static Criteria where(Field field)
          Static factory method to create a new Criteria for provided field
static Criteria where(String field)
          Static factory method to create a new Criteria for field with given name
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WILDCARD

public static final String WILDCARD
See Also:
Constant Field Values

CRITERIA_VALUE_SEPERATOR

public static final String CRITERIA_VALUE_SEPERATOR
See Also:
Constant Field Values
Constructor Detail

Criteria

public Criteria()

Criteria

public Criteria(String fieldname)
Creates a new CriterSimpleFieldia for the Filed with provided name

Parameters:
fieldname -

Criteria

public Criteria(Field field)
Creates a new Criteria for the given field

Parameters:
field -

Criteria

protected Criteria(List<Criteria> criteriaChain,
                   String fieldname)

Criteria

protected Criteria(List<Criteria> criteriaChain,
                   Field field)
Method Detail

where

public static Criteria where(String field)
Static factory method to create a new Criteria for field with given name

Parameters:
field -
Returns:

where

public static Criteria where(Field field)
Static factory method to create a new Criteria for provided field

Parameters:
field -
Returns:

and

public Criteria and(Field field)
Chain using AND

Parameters:
field -
Returns:

and

public Criteria and(String fieldName)
Chain using AND

Parameters:
fieldName -
Returns:

and

public Criteria and(Criteria criteria)
Chain using AND

Parameters:
criteria -
Returns:

and

public Criteria and(Criteria... criterias)
Chain using AND

Parameters:
criterias -
Returns:

or

public Criteria or(Field field)
Chain using OR

Parameters:
field -
Returns:

or

public Criteria or(Criteria criteria)
Chain using OR

Parameters:
criteria -
Returns:

or

public Criteria or(String fieldName)
Chain using OR

Parameters:
fieldName -
Returns:

is

public Criteria is(Object o)
Crates new CriteriaEntry without any wildcards

Parameters:
o -
Returns:

contains

public Criteria contains(String s)
Crates new CriteriaEntry with leading and trailing wildcards
NOTE: mind your schema as leading wildcards may not be supported and/or execution might be slow.

Parameters:
s -
Returns:

startsWith

public Criteria startsWith(String s)
Crates new CriteriaEntry with trailing wildcard

Parameters:
s -
Returns:

endsWith

public Criteria endsWith(String s)
Crates new CriteriaEntry with leading wildcard
NOTE: mind your schema and execution times as leading wildcards may not be supported.

Parameters:
s -
Returns:

not

public Criteria not()
Crates new CriteriaEntry with trailing -

Returns:

fuzzy

public Criteria fuzzy(String s)
Crates new CriteriaEntry with trailing ~

Parameters:
s -
Returns:

expression

public Criteria expression(String s)
Crates new CriteriaEntry allowing native elasticsearch expressions

Parameters:
s -
Returns:

boost

public Criteria boost(float boost)
Boost positive hit with given factor. eg. ^2.3

Parameters:
boost -
Returns:

between

public Criteria between(Object lowerBound,
                        Object upperBound)
Crates new CriteriaEntry for RANGE [lowerBound TO upperBound]

Parameters:
lowerBound -
upperBound -
Returns:

lessThanEqual

public Criteria lessThanEqual(Object upperBound)
Crates new CriteriaEntry for RANGE [* TO upperBound]

Parameters:
upperBound -
Returns:

greaterThanEqual

public Criteria greaterThanEqual(Object lowerBound)
Crates new CriteriaEntry for RANGE [lowerBound TO *]

Parameters:
lowerBound -
Returns:

in

public Criteria in(Object... values)
Crates new CriteriaEntry for multiple values (arg0 arg1 arg2 ...)

Parameters:
values -
Returns:

in

public Criteria in(Iterable<?> values)
Crates new CriteriaEntry for multiple values (arg0 arg1 arg2 ...)

Parameters:
values - the collection containing the values to match against
Returns:

getField

public Field getField()
Field targeted by this Criteria

Returns:

getCriteriaEntries

public Set<Criteria.CriteriaEntry> getCriteriaEntries()

getConjunctionOperator

public String getConjunctionOperator()
Conjunction to be used with this criteria (AND | OR)

Returns:

getCriteriaChain

public List<Criteria> getCriteriaChain()

isNegating

public boolean isNegating()

isAnd

public boolean isAnd()

isOr

public boolean isOr()

getBoost

public float getBoost()

Spring Data Elasticsearch

Copyright © 2012-2013 BioMed Central. All Rights Reserved.