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 testMultilineQuery() throws ParseException {
        final ParsedQuery query = parser.parse("foo:bar AND\nlorem:ipsum");

        assertThat(query.tokens())
                .anySatisfy(token -> {
                    assertThat(token.image()).isEqualTo("foo");
                    assertThat(token.beginLine()).isEqualTo(1);
                    assertThat(token.beginColumn()).isEqualTo(0);
                    assertThat(token.endLine()).isEqualTo(1);
                    assertThat(token.endColumn()).isEqualTo(3);
                })
                .anySatisfy(token -> {
                    assertThat(token.image()).isEqualTo("lorem");
                    assertThat(token.beginLine()).isEqualTo(2);
                    assertThat(token.beginColumn()).isEqualTo(0);
                    assertThat(token.endLine()).isEqualTo(2);
                    assertThat(token.endColumn()).isEqualTo(5);
                })
                .anySatisfy(token -> {
                    assertThat(token.image()).isEqualTo("ipsum");
                    assertThat(token.beginLine()).isEqualTo(2);
                    assertThat(token.beginColumn()).isEqualTo(6);
                    assertThat(token.endLine()).isEqualTo(2);
                    assertThat(token.endColumn()).isEqualTo(11);
                });
    }