@Test public void conjunctionsOutweighDisjunctions() throws Exception { Query bq = ParserUtils.parse("field1:term1 +field1:term2"); assertThat(treeBuilder.collectTerms(bq)) .containsOnly(new QueryTerm("field1", "term2", QueryTerm.Type.EXACT)); }
@Test public void allNestedDisjunctionClausesAreIncluded() throws Exception { Query q = ParserUtils.parse("field1:term3 (field1:term1 field1:term2)"); assertThat(treeBuilder.collectTerms(q)).hasSize(3); }
@Test public void allDisjunctionClausesOfAConjunctionAreExtracted() throws Exception { Query q = ParserUtils.parse("+(field1:term1 field1:term2) field1:term3"); assertThat(treeBuilder.collectTerms(q)).hasSize(2); }
@Test public void disjunctionsWithMatchAllNegativeClausesReturnANYTOKEN() throws Exception { Query q = ParserUtils.parse("+field1:term1 +(field2:term22 (*:* -field2:notterm))"); assertThat(treeBuilder.collectTerms(q)) .containsOnly(new QueryTerm("field1", "term1", QueryTerm.Type.EXACT)); }
@Test public void allDisjunctionQueriesAreIncluded() throws Exception { Query bq = ParserUtils.parse("field1:term1 field1:term2"); List<QueryTerm> terms = treeBuilder.collectTerms(bq); assertThat(terms) .containsOnly( new QueryTerm("field1", "term1", QueryTerm.Type.EXACT), new QueryTerm("field1", "term2", QueryTerm.Type.EXACT)); }