@Override public String explain() { String baseExplain = super.explain(); Where where = this.connectedWhere; QueryBuilder explan = null; try { if (where != null) explan = QueryMaker.explan(where, false); } catch (SqlParseException e) { } String conditions = explan == null ? "Could not parse conditions" : explan.toString(); String nestedExplain = "Nested Loops \n run first query , and for each result run second query with additional conditions :\n" + conditions + "\n" + baseExplain; return nestedExplain; }
public List<String> autocomplete(String prefix, int limit) { SearchRequestBuilder builder = new SearchRequestBuilder(factory.client()); builder.setIndices(Constants.INDEX).setTypes(Constants.TYPE); builder.setSearchType(SearchType.DEFAULT); builder.setFrom(0).setSize(limit).setExplain(IS_EXPLAIN); QueryBuilder queryBuilder = QueryBuilders.matchPhraseQuery("title", prefix); builder.setQuery(queryBuilder.toString()); logger.info("Search qeury"); logger.info(builder.toString()); SearchResponse sr = builder.execute().actionGet(); logger.info("Search response"); logger.info(sr.toString()); Iterator<SearchHit> it = sr.getHits().iterator(); while (it.hasNext()) { SearchHit hit = it.next(); hit.getSource(); } return Arrays.asList("a", "b", "c"); }