public void testCaretQueries() throws InterruptedException, ParseException, Exception {
DocumentSearcher searcher = this.indexEngine.getSearcher();
BoostingIndexer indexer = this.indexEngine.getIndexer();
indexer.addScoreFunction(1, "relevance");
Document doc;
Query query;
doc = new Document(ImmutableMap.of("text", "aaa"));
indexer.add("1", doc, 0, ImmutableMap.<Integer, Double>of());
doc = new Document(ImmutableMap.of("text", "aaa bbb"));
indexer.add("2", doc, 0, ImmutableMap.<Integer, Double>of());
doc = new Document(ImmutableMap.of("text", "aaa aaa bbb"));
indexer.add("3", doc, 0, ImmutableMap.<Integer, Double>of());
doc = new Document(ImmutableMap.of("text", "aaa bbb ccc eee"));
indexer.add("4", doc, 0, ImmutableMap.<Integer, Double>of());
doc = new Document(ImmutableMap.of("text", "ccc ddd"));
indexer.add("5", doc, 0, ImmutableMap.<Integer, Double>of());
query = new Query(indexEngine.getParser().parseQuery("aaa"),null,null);
checkResults("Caret", searcher, query, 1, new String[] {"1","3","2","4"});
query = new Query(indexEngine.getParser().parseQuery("aaa AND bbb"),null,null);
checkResults("Caret", searcher, query, 1, new String[] {"2","3","4"});
query = new Query(indexEngine.getParser().parseQuery("aaa OR bbb"),null,null);
checkResults("Caret", searcher, query, 1, new String[] {"2","3","1","4"});
query = new Query(indexEngine.getParser().parseQuery("aaa^2 OR bbb"),null,null);
checkResults("Caret", searcher, query, 1, new String[] {"3","2","1","4"});
query = new Query(indexEngine.getParser().parseQuery("aaa OR bbb^2"),null,null);
checkResults("Caret", searcher, query, 1, new String[] {"2","3","4","1"});
query = new Query(indexEngine.getParser().parseQuery("ccc OR ddd"),null,null);
checkResults("Caret", searcher, query, 1, new String[] {"5","4"});
query = new Query(indexEngine.getParser().parseQuery("ccc OR ddd OR eee^2"),null,null);
checkResults("Caret", searcher, query, 1, new String[] {"4","5"});
}