// Path: src/com/winterwell/es/client/agg/AggregationResults.java
// public class AggregationResults {
// 
// 	private String name;
// 	private Map results;
// 
// 	public AggregationResults(String aggName, Map rs) {
// 		this.name = aggName;
// 		this.results = rs;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return "AggregationResults[ "+name+": "+results+"]";
// 	}
// }


import java.util.List;
import java.util.Map;
import com.winterwell.es.client.agg.AggregationResults;
import com.winterwell.web.WebEx;
package com.winterwell.es.client;



public interface SearchResponse extends IESResponse {

	/**
	 * @return List of hits, which are wrapper objects around a _source document.
	 * @throws WebEx if the search failed.
	 */
	List<Map> getHits();

	Map getFacets();

	
	
	/**
	 * The initial search request and each subsequent scroll request returns a new scroll_id.
	 * <b>Only the most recent scroll_id should be used.</b>
	 * @return the new scroll_id for the next request
	 */
	String getScrollId();

	/**
	 * @return the total possible number results which could be returned for query, 
	 * not necessarily the amount which WILL be returned (See ResultsPerPage)
	 * 
	 */
	long getTotal();

	Map getAggregations();

	/**
	 * Like {@link #getHits()} then get _source, but without any gson to-POJO conversion.
	 * @return list of documents
	 * @see #getSearchResults(Class)
	 */
	List<Map<String,Object>> getSearchResults();
	
	<X> List<X> getSearchResults(Class<? extends X> klass);

// Path: src/com/winterwell/es/client/agg/AggregationResults.java
// public class AggregationResults {
// 
// 	private String name;
// 	private Map results;
// 
// 	public AggregationResults(String aggName, Map rs) {
// 		this.name = aggName;
// 		this.results = rs;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return "AggregationResults[ "+name+": "+results+"]";
// 	}
// }


// Path: src/com/winterwell/es/client/SearchResponse.java
import java.util.List;
import java.util.Map;
import com.winterwell.es.client.agg.AggregationResults;
import com.winterwell.web.WebEx;

package com.winterwell.es.client;



public interface SearchResponse extends IESResponse {

	/**
	 * @return List of hits, which are wrapper objects around a _source document.
	 * @throws WebEx if the search failed.
	 */
	List<Map> getHits();

	Map getFacets();

	
	
	/**
	 * The initial search request and each subsequent scroll request returns a new scroll_id.
	 * <b>Only the most recent scroll_id should be used.</b>
	 * @return the new scroll_id for the next request
	 */
	String getScrollId();

	/**
	 * @return the total possible number results which could be returned for query, 
	 * not necessarily the amount which WILL be returned (See ResultsPerPage)
	 * 
	 */
	long getTotal();

	Map getAggregations();

	/**
	 * Like {@link #getHits()} then get _source, but without any gson to-POJO conversion.
	 * @return list of documents
	 * @see #getSearchResults(Class)
	 */
	List<Map<String,Object>> getSearchResults();
	
	<X> List<X> getSearchResults(Class<? extends X> klass);

	AggregationResults getAggregationResults(String name);