public ParsedQuery parse(final String query) throws ParseException {
        final TokenCollectingQueryParser parser = new TokenCollectingQueryParser(ParsedTerm.DEFAULT_FIELD, ANALYZER);
        parser.setSplitOnWhitespace(true);
        parser.setAllowLeadingWildcard(allowLeadingWildcard);

        final Query parsed = parser.parse(query);
        final ParsedQuery.Builder builder = ParsedQuery.builder().query(query);

        builder.tokensBuilder().addAll(parser.getTokens());

        final TermCollectingQueryVisitor visitor = new TermCollectingQueryVisitor(ANALYZER, parser.getTokenLookup());
        parsed.visit(visitor);
        builder.termsBuilder().addAll(visitor.getParsedTerms());
        return builder.build();
    }
@Test
    void testMultilineComplexQuery() throws ParseException {
        final ParsedQuery query = parser.parse("(\"ssh login\" AND (source:example.org OR source:another.example.org))\n" +
                "OR (\"login\" AND (source:example1.org OR source:another.example2.org))\n" +
                "OR not_existing_field:test");

        assertThat(query.tokens())
                .anySatisfy( token -> {
                    assertThat(token.image()).isEqualTo("not_existing_field");
                    assertThat(token.beginLine()).isEqualTo(3);
                    assertThat(token.beginColumn()).isEqualTo(3);
                    assertThat(token.endLine()).isEqualTo(3);
                    assertThat(token.endColumn()).isEqualTo(21);
                });
    }