Class FilterExpressionBuilder
java.lang.Object
org.springframework.ai.vectorstore.filter.FilterExpressionBuilder
DSL builder for
Filter.Expression
instances. Here are some common examples:
var b = new FilterExpressionBuilder();
// 1: country == "BG"
var exp1 = b.eq("country", "BG");
// 2: genre == "drama" AND year >= 2020
var exp2 = b.and(b.eq("genre", "drama"), b.gte("year", 2020));
// 3: genre in ["comedy", "documentary", "drama"]
var exp3 = b.in("genre", "comedy", "documentary", "drama");
// 4: year >= 2020 OR country == "BG" AND city != "Sofia"
var exp4 = b.and(b.or(b.gte("year", 2020), b.eq("country", "BG")), b.ne("city", "Sofia"));
// 5: (year >= 2020 OR country == "BG") AND city NIN ["Sofia", "Plovdiv"]
var exp5 = b.and(b.group(b.or(b.gte("year", 2020), b.eq("country", "BG"))), b.nin("city", "Sofia", "Plovdiv"));
// 6: isOpen == true AND year >= 2020 AND country IN ["BG", "NL", "US"]
var exp6 = b.and(b.and(b.eq("isOpen", true), b.gte("year", 2020)), b.in("country", "BG", "NL", "US"));
This builder DSL mimics the common https://www.baeldung.com/hibernate-criteria-queries
syntax.- Author:
- Christian Tzolov
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionand
(FilterExpressionBuilder.Op left, FilterExpressionBuilder.Op right) group
(FilterExpressionBuilder.Op content) not
(FilterExpressionBuilder.Op content) or
(FilterExpressionBuilder.Op left, FilterExpressionBuilder.Op right)
-
Constructor Details
-
FilterExpressionBuilder
public FilterExpressionBuilder()
-
-
Method Details
-
eq
-
ne
-
gt
-
gte
-
lt
-
lte
-
and
public FilterExpressionBuilder.Op and(FilterExpressionBuilder.Op left, FilterExpressionBuilder.Op right) -
or
public FilterExpressionBuilder.Op or(FilterExpressionBuilder.Op left, FilterExpressionBuilder.Op right) -
in
-
in
-
nin
-
nin
-
group
-
not
-