java.lang.Object
org.springframework.ai.vectorstore.filter.Filter

public class Filter extends Object
Portable runtime model for metadata filter expressions. This generic model is used to define store agnostic filter expressions than later can be converted into vector-store specific, native, expressions. The expression model supports constant comparison (e.g. ==, !=, <, <=, >, >=) , IN/NON-IN checks and AND and OR to compose multiple expressions. For example:

 // 1: country == "BG"
 new Expression(EQ, new Key("country"), new Value("BG"));

 // 2: genre == "drama" AND year >= 2020
 new Expression(AND, new Expression(EQ, new Key("genre"), new Value("drama")),
 		new Expression(GTE, new Key("year"), new Value(2020)));

 // 3: genre in ["comedy", "documentary", "drama"]
 new Expression(IN, new Key("genre"), new Value(List.of("comedy", "documentary", "drama")));

 // 4: year >= 2020 OR country == "BG" AND city != "Sofia"
 new Expression(OR, new Expression(GTE, new Key("year"), new Value(2020)),
 		new Expression(AND, new Expression(EQ, new Key("country"), new Value("BG")),
 				new Expression(NE, new Key("city"), new Value("Sofia"))));

 // 5: (year >= 2020 OR country == "BG") AND city NIN ["Sofia", "Plovdiv"]
 new Expression(AND,
 		new Group(new Expression(OR, new Expression(EQ, new Key("country"), new Value("BG")),
 				new Expression(GTE, new Key("year"), new Value(2020)))),
 		new Expression(NIN, new Key("city"), new Value(List.of("Sofia", "Varna"))));

 // 6: isOpen == true AND year >= 2020 AND country IN ["BG", "NL", "US"]
 new Expression(AND, new Expression(EQ, new Key("isOpen"), new Value(true)),
 		new Expression(AND, new Expression(GTE, new Key("year"), new Value(2020)),
 				new Expression(IN, new Key("country"), new Value(List.of("BG", "NL", "US")))));

 
Usually you will not create expression manually but use either the builder() DSL or the parser() for parsing generic text expressions. Follow the FilterExpressionBuilder and FilterExpressionTextParser documentation for how to use them.
Author:
Christian Tzolov