java.lang.Object
org.springframework.data.solr.core.query.Node
org.springframework.data.solr.core.query.Criteria
Direct Known Subclasses:
AnyCriteria, Crotch, SimpleStringCriteria

public class Criteria extends Node
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.
  • Field Details

  • Constructor Details

    • Criteria

      public Criteria()
    • Criteria

      public Criteria(Function function)
      Parameters:
      function -
      Since:
      1.1
    • Criteria

      public Criteria(String fieldname)
      Creates a new Criteria for the Filed with provided name
      Parameters:
      fieldname -
    • Criteria

      public Criteria(Field field)
      Creates a new Criteria for the given field
      Parameters:
      field -
  • Method Details

    • where

      public static Criteria where(String fieldname)
      Static factory method to create a new Criteria for field with given name
      Parameters:
      fieldname - must not be null
      Returns:
    • where

      public static Criteria where(Function function)
      Static factory method to create a new Criteria for function
      Parameters:
      function - must not be null
      Returns:
      Since:
      1.1
    • where

      public static Criteria where(Field field)
      Static factory method to create a new Criteria for provided field
      Parameters:
      field - must not be null
      Returns:
    • is

      public Criteria is(@Nullable Object o)
      Crates new Criteria.Predicate without any wildcards. Strings with blanks will be escaped "string\ with\ blank"
      Specified by:
      is in class Node
      Parameters:
      o -
      Returns:
    • is

      public Criteria is(Object... values)
      Crates new Criteria.Predicate without any wildcards for each entry
      Specified by:
      is in class Node
      Parameters:
      values -
      Returns:
    • is

      public Criteria is(Iterable<?> values)
      Creates new Criteria.Predicate without any wildcards for each entry
      Specified by:
      is in class Node
      Parameters:
      values -
      Returns:
    • isNull

      public Criteria isNull()
      Crates new Criteria.Predicate for null values
      Specified by:
      isNull in class Node
      Returns:
    • isNotNull

      public Criteria isNotNull()
      Crates new Criteria.Predicate for !null values
      Specified by:
      isNotNull in class Node
      Returns:
    • contains

      public Criteria contains(String s)
      Crates new Criteria.Predicate with leading and trailing wildcards
      NOTE: mind your schema as leading wildcards may not be supported and/or execution might be slow. NOTE: Strings will not be automatically split on whitespace.
      Specified by:
      contains in class Node
      Parameters:
      s -
      Returns:
      Throws:
      org.springframework.dao.InvalidDataAccessApiUsageException - for strings with whitespace
    • contains

      public Criteria contains(String... values)
      Crates new Criteria.Predicate with leading and trailing wildcards for each entry
      NOTE: mind your schema as leading wildcards may not be supported and/or execution might be slow.
      Specified by:
      contains in class Node
      Parameters:
      values -
      Returns:
      Throws:
      org.springframework.dao.InvalidDataAccessApiUsageException - for strings with whitespace
    • contains

      public Criteria contains(Iterable<String> values)
      Crates new Criteria.Predicate with leading and trailing wildcards for each entry
      NOTE: mind your schema as leading wildcards may not be supported and/or execution might be slow.
      Specified by:
      contains in class Node
      Parameters:
      values -
      Returns:
      Throws:
      org.springframework.dao.InvalidDataAccessApiUsageException - for strings with whitespace
    • startsWith

      public Criteria startsWith(String s)
      Crates new Criteria.Predicate with trailing wildcard
      NOTE: Strings will not be automatically split on whitespace.
      Specified by:
      startsWith in class Node
      Parameters:
      s -
      Returns:
      Throws:
      org.springframework.dao.InvalidDataAccessApiUsageException - for strings with whitespace
    • startsWith

      public Criteria startsWith(String... values)
      Crates new Criteria.Predicate with trailing wildcard for each entry
      Specified by:
      startsWith in class Node
      Parameters:
      values -
      Returns:
      Throws:
      org.springframework.dao.InvalidDataAccessApiUsageException - for strings with whitespace
    • startsWith

      public Criteria startsWith(Iterable<String> values)
      Crates new Criteria.Predicate with trailing wildcard for each entry
      Specified by:
      startsWith in class Node
      Parameters:
      values -
      Returns:
      Throws:
      org.springframework.dao.InvalidDataAccessApiUsageException - for strings with whitespace
    • endsWith

      public Criteria endsWith(String s)
      Crates new Criteria.Predicate with leading wildcard
      NOTE: mind your schema and execution times as leading wildcards may not be supported. NOTE: Strings will not be automatically split on whitespace.
      Specified by:
      endsWith in class Node
      Parameters:
      s -
      Returns:
      Throws:
      org.springframework.dao.InvalidDataAccessApiUsageException - for strings with whitespace
    • endsWith

      public Criteria endsWith(String... values)
      Crates new Criteria.Predicate with leading wildcard for each entry
      NOTE: mind your schema and execution times as leading wildcards may not be supported.
      Specified by:
      endsWith in class Node
      Parameters:
      values -
      Returns:
      Throws:
      org.springframework.dao.InvalidDataAccessApiUsageException - for strings with whitespace
    • endsWith

      public Criteria endsWith(Iterable<String> values)
      Crates new Criteria.Predicate with leading wildcard for each entry
      NOTE: mind your schema and execution times as leading wildcards may not be supported.
      Specified by:
      endsWith in class Node
      Parameters:
      values -
      Returns:
      Throws:
      org.springframework.dao.InvalidDataAccessApiUsageException - for strings with whitespace
    • not

      public Criteria not()
      Negates current criteria usinng - operator
      Specified by:
      not in class Node
      Returns:
    • notOperator

      public Criteria notOperator()
      Explicitly wrap Criteria inside not operation.
      Returns:
      Since:
      1.4
    • fuzzy

      public Criteria fuzzy(String s)
      Crates new Criteria.Predicate with trailing ~
      Specified by:
      fuzzy in class Node
      Parameters:
      s -
      Returns:
    • fuzzy

      public Criteria fuzzy(String s, float levenshteinDistance)
      Crates new Criteria.Predicate with trailing ~ followed by levensteinDistance
      Specified by:
      fuzzy in class Node
      Parameters:
      s -
      levenshteinDistance -
      Returns:
    • sloppy

      public Criteria sloppy(String phrase, int distance)
      Crates new Criteria.Predicate with trailing ~ followed by distance
      Specified by:
      sloppy in class Node
      Parameters:
      phrase -
      distance -
      Returns:
    • expression

      public Criteria expression(String s)
      Crates new Criteria.Predicate allowing native solr expressions
      Specified by:
      expression in class Node
      Parameters:
      s -
      Returns:
    • boost

      public Criteria boost(float boost)
      Boost positive hit with given factor. eg. ^2.3
      Specified by:
      boost in class Node
      Parameters:
      boost -
      Returns:
    • between

      public Criteria between(@Nullable Object lowerBound, @Nullable Object upperBound)
      Crates new Criteria.Predicate for RANGE [lowerBound TO upperBound]
      Specified by:
      between in class Node
      Parameters:
      lowerBound -
      upperBound -
      Returns:
    • between

      public Criteria between(@Nullable Object lowerBound, @Nullable Object upperBound, boolean includeLowerBound, boolean includeUppderBound)
      Crates new Criteria.Predicate for RANGE [lowerBound TO upperBound]
      Specified by:
      between in class Node
      Parameters:
      lowerBound -
      upperBound -
      includeLowerBound -
      includeUppderBound -
      Returns:
    • lessThan

      public Criteria lessThan(Object upperBound)
      Crates new Criteria.Predicate for RANGE [* TO upperBound&#125;
      Specified by:
      lessThan in class Node
      Parameters:
      upperBound -
      Returns:
    • lessThanEqual

      public Criteria lessThanEqual(Object upperBound)
      Crates new Criteria.Predicate for RANGE [* TO upperBound]
      Specified by:
      lessThanEqual in class Node
      Parameters:
      upperBound -
      Returns:
    • greaterThan

      public Criteria greaterThan(Object lowerBound)
      Crates new Criteria.Predicate for RANGE &#123;lowerBound TO *]
      Specified by:
      greaterThan in class Node
      Parameters:
      lowerBound -
      Returns:
    • greaterThanEqual

      public Criteria greaterThanEqual(Object lowerBound)
      Crates new Criteria.Predicate for RANGE [lowerBound TO *]
      Specified by:
      greaterThanEqual in class Node
      Parameters:
      lowerBound -
      Returns:
    • in

      public Criteria in(Object... values)
      Crates new Criteria.Predicate for multiple values (arg0 arg1 arg2 ...)
      Specified by:
      in in class Node
      Parameters:
      values -
      Returns:
    • in

      public Criteria in(Iterable<?> values)
      Crates new Criteria.Predicate for multiple values (arg0 arg1 arg2 ...)
      Specified by:
      in in class Node
      Parameters:
      values - the collection containing the values to match against
      Returns:
    • within

      public Criteria within(org.springframework.data.geo.Point location, @Nullable org.springframework.data.geo.Distance distance)
      Creates new Criteria.Predicate for !getfilt.
      Uses non neutral metric to set the local score property for the function.
      Specified by:
      within in class Node
      Parameters:
      location - Point in degrees
      distance -
      Returns:
    • within

      public Criteria within(org.springframework.data.geo.Circle circle)
      Creates new Criteria.Predicate for !getfilt.
      Parameters:
      circle -
      Returns:
      Since:
      1.2
    • near

      public Criteria near(org.springframework.data.geo.Box box)
      Creates new Criteria.Predicate for !bbox with exact coordinates.
      Specified by:
      near in class Node
      Parameters:
      box -
      Returns:
    • near

      public Criteria near(org.springframework.data.geo.Point location, @Nullable org.springframework.data.geo.Distance distance)
      Creates new Criteria.Predicate for !bbox for a specified distance. The difference between this and within is this is approximate while within is exact.
      Uses non neutral metric to set the local score property for the function.
      Specified by:
      near in class Node
      Parameters:
      location -
      distance -
      Returns:
      Throws:
      IllegalArgumentException - if location is null
      org.springframework.dao.InvalidDataAccessApiUsageException - if distance is negative
    • near

      public Criteria near(org.springframework.data.geo.Circle circle)
      Creates new Criteria.Predicate for !circle for a specified distance. The difference between this and within(Circle) is this is approximate while within is exact.
      Uses non neutral metric to set the local score property for the function.
      Parameters:
      circle -
      Returns:
      Since:
      1.2
    • function

      public Criteria function(Function function)
      Creates Criteria.Predicate for given Function.
      Specified by:
      function in class Node
      Parameters:
      function - must not be null
      Returns:
      Throws:
      IllegalArgumentException - if function is null
      Since:
      1.1
    • getField

      @Nullable public Field getField()
      Target field
      Returns:
      null if not set
    • isNegating

      public boolean isNegating()
      Overrides:
      isNegating in class Node
      Returns:
      true if not() criteria
    • getBoost

      public float getBoost()
      Boost criteria value
      Returns:
      Float.NaN if not set
    • getPredicates

      public Set<Criteria.Predicate> getPredicates()
      Returns:
      unmodifiable set of all Criteria.Predicate
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • connect

      public Criteria connect()
      Explicitly connect Criteria with another one allows to create explicit bracketing.
      Returns:
      Since:
      1.4
    • and

      public Crotch and(Node node)
      Description copied from class: Node
      Combine two Nodes using and.
      Specified by:
      and in class Node
      Returns:
    • and

      public Crotch and(String fieldname)
      Description copied from class: Node
      Combine node with new Node for given fieldname using and.
      Specified by:
      and in class Node
      Returns:
    • or

      public Crotch or(Node node)
      Description copied from class: Node
      Combine two Nodes using or.
      Specified by:
      or in class Node
      Returns:
    • or

      public Crotch or(String fieldname)
      Description copied from class: Node
      Combine node with new Node for given fieldname using and.
      Specified by:
      or in class Node
      Returns: