org.das2.util.BooleanSearch

Small Boolean full-text search parser. Requires Java 8 or later.

Operators (case-insensitive): NOT, AND, OR, in descending precedence. Adjacent terms imply AND. Parentheses group expressions; double quotes match literal phrases. A minus sign at the start of a term means NOT. Searches are case-insensitive substring matches, not whole-word matches.

Example: {@code BooleanSearch.compile("(rbsp OR themis) AND density")}


compile

compile( String query ) → java.util.function.Predicate

Compiles a query once for use against many strings.

Parameters

query - a String

Returns:

java.util.function.Predicate

[search for examples] [view on GitHub] [view on old javadoc] [view source]


compileLenient

compileLenient( String query ) → java.util.function.Predicate

Compiles a partially typed query for interactive search fields. Incomplete trailing operators and empty opening groups are discarded; unmatched opening parentheses are closed automatically. An unfinished quoted phrase is treated as a phrase extending to the end of the query. Other syntax errors are still reported.

Parameters

query - a String

Returns:

java.util.function.Predicate

[search for examples] [view on GitHub] [view on old javadoc] [view source]


matches

matches( String query, String text ) → boolean

Convenience method for one-off matches.

Parameters

query - a String
text - a String

Returns:

boolean

[search for examples] [view on GitHub] [view on old javadoc] [view source]