Skip to content

Wildcard.toAutomaton consumes an excessive amount with repeated asterisks. #16134

Description

@csatl

Description

When a wildcard contains repeated asterisks the memory consumption is quadratic because automaton.Operations.concatenate has to keep chaining if there patterns match empty strings.

This can all be avoided by just ignoring repeated asterisks.

WildcardQuery.toAutomaton(new Term("field", "*".repeat(10000))

Version and environment details

Lucene 10.2.2 with Opensearch 2.19.5 but can replicate the same behaviour with the main branch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions