Skip to main content

πŸ“˜ Wildcard and Regex queries

There are two similar operators that perform pattern matching: wildcard and regex.

Analyzer considerations​

The analyzer determines what is matchable. lucene.keyword to match across the entire string. Any other analyzer to match across the pieces of its output.

Static prefix matters: index scan, or only prefix-matching slice scanned.

wildcard​

The wildcard operator supports only two wildcard characters, ? and * which can be placed anywhere in the query string, one or more of them.

  • ?: Matches any single character
  • *: Matches zero or more characters

This is a useful operator to match strings starting with a particular prefix, by adding * to the end. For example, a wildcard expression of ho* would match "horse" and "house".

regex​

The regex operator supports a robust regular expression syntax, able to match sophisticated patterns against the terms of an inverted index.