fluid-api/src/main/java/com/fluidbpm/program/api/util/elasticsearch/ABaseESUtil.java
public final List<Form> searchAndConvertHitsToFormWithAllFields(
			QueryBuilder qbParam,
			String indexParam,
			int offsetParam,
			int limitParam,
			Long ... formTypesParam
	) {
		SearchHits searchHits = this.searchWithHits(
				qbParam,
				indexParam,
				false,
				offsetParam,
				limitParam,
				formTypesParam);

		List<Form> returnVal = null;

		long totalHits;
		if (searchHits != null && (totalHits = searchHits.getTotalHits()) > 0) {
			returnVal = new ArrayList();

			if((searchHits.getHits().length != totalHits) &&
					(searchHits.getHits().length != limitParam)) {
				throw new FluidElasticSearchException(
						"The Hits and fetch count has mismatch. Total hits is '"+totalHits+"' while hits is '"+
								searchHits.getHits().length+"'.");
			}

			long iterationMax = totalHits;
			if(limitParam > 0 && totalHits > limitParam) {
				iterationMax = limitParam;
			}

			//Iterate...
			for(int index = 0;index < iterationMax;index++) {
				SearchHit searchHit = searchHits.getAt(index);

				String source;
				if((source = searchHit.getSourceAsString()) == null) {
					continue;
				}

				this.printInfoOnSourceFromES(searchHit);

				Form formFromSource = new Form();

				JSONObject jsonObject = new JSONObject(source);
				List<Field> fieldsForForm = null;
				//Is Form Type available...
				if(jsonObject.has(Form.JSONMapping.FORM_TYPE_ID)) {
					if(this.fieldUtil == null) {
						throw new FluidElasticSearchException(
								"Field Util is not set. Use a different constructor.");
					}

					fieldsForForm = formFromSource.convertTo(
							this.fieldUtil.getFormFieldMappingForFormDefinition(
									jsonObject.getLong(Form.JSONMapping.FORM_TYPE_ID)));
				}

				formFromSource.populateFromElasticSearchJson(
						jsonObject, fieldsForForm);

				returnVal.add(formFromSource);
			}
		}

		return returnVal;
	}
public final List<Form> searchAndConvertHitsToFormWithAllFields(
			QueryBuilder qbParam,
			String indexParam,
			int offsetParam,
			int limitParam,
			Long ... formTypesParam
	) {
		SearchHits searchHits = this.searchWithHits(
				qbParam,
				indexParam,
				false,
				offsetParam,
				limitParam,
				formTypesParam);

		List<Form> returnVal = null;

		long totalHits;
		if (searchHits != null && (totalHits = searchHits.getTotalHits()) > 0) {
			returnVal = new ArrayList();

			if((searchHits.getHits().length != totalHits) &&
					(searchHits.getHits().length != limitParam)) {
				throw new FluidElasticSearchException(
						"The Hits and fetch count has mismatch. Total hits is '"+totalHits+"' while hits is '"+
								searchHits.getHits().length+"'.");
			}

			long iterationMax = totalHits;
			if(limitParam > 0 && totalHits > limitParam) {
				iterationMax = limitParam;
			}

			//Iterate...
			for(int index = 0;index < iterationMax;index++) {
				SearchHit searchHit = searchHits.getAt(index);

				String source;
				if((source = searchHit.getSourceAsString()) == null) {
					continue;
				}

				this.printInfoOnSourceFromES(searchHit);

				Form formFromSource = new Form();

				JSONObject jsonObject = new JSONObject(source);
				List<Field> fieldsForForm = null;
				//Is Form Type available...
				if(jsonObject.has(Form.JSONMapping.FORM_TYPE_ID)) {
					if(this.fieldUtil == null) {
						throw new FluidElasticSearchException(
								"Field Util is not set. Use a different constructor.");
					}

					fieldsForForm = formFromSource.convertTo(
							this.fieldUtil.getFormFieldMappingForFormDefinition(
									jsonObject.getLong(Form.JSONMapping.FORM_TYPE_ID)));
				}

				formFromSource.populateFromElasticSearchJson(
						jsonObject, fieldsForForm);

				returnVal.add(formFromSource);
			}
		}

		return returnVal;
	}
public final List < Form > searchAndConvertHitsToFormWithAllFields ( QueryBuilder qbParam , String indexParam , int offsetParam , int limitParam , Long ... formTypesParam ) { SearchHits searchHits = this . searchWithHits ( qbParam , indexParam , false , offsetParam , limitParam , formTypesParam ) ; List < Form > returnVal = null ; long totalHits ; if ( searchHits != null && ( totalHits = searchHits . getTotalHits ( ) ) > 0 ) { returnVal = new ArrayList ( ) ; if ( ( searchHits . getHits ( ) . length != totalHits ) && ( searchHits . getHits ( ) . length != limitParam ) ) { throw new FluidElasticSearchException ( "The Hits and fetch count has mismatch. Total hits is '" + totalHits + "' while hits is '" + searchHits . getHits ( ) . length + "'." ) ; } long iterationMax = totalHits ; if ( limitParam > 0 && totalHits > limitParam ) { iterationMax = limitParam ; } //Iterate... for ( int index = 0 ; index < iterationMax ; index ++ ) { SearchHit searchHit = searchHits . getAt ( index ) ; String source ; if ( ( source = searchHit . getSourceAsString ( ) ) == null ) { continue ; } this . printInfoOnSourceFromES ( searchHit ) ; Form formFromSource = new Form ( ) ; JSONObject jsonObject = new JSONObject ( source ) ; List < Field > fieldsForForm = null ; //Is Form Type available... if ( jsonObject . has ( Form . JSONMapping . FORM_TYPE_ID ) ) { if ( this . fieldUtil == null ) { throw new FluidElasticSearchException ( "Field Util is not set. Use a different constructor." ) ; } fieldsForForm = formFromSource . convertTo ( this . fieldUtil . getFormFieldMappingForFormDefinition ( jsonObject . getLong ( Form . JSONMapping . FORM_TYPE_ID ) ) ) ; } formFromSource . populateFromElasticSearchJson ( jsonObject , fieldsForForm ) ; returnVal . add ( formFromSource ) ; } } return returnVal ; }
Performs a search against the Elasticsearch instance with the {@code qbParam}.

@param qbParam The @{code QueryBuilder} to search with.
@param indexParam The Elasticsearch Index to use {@code (document, folder or table_field)}.
@param offsetParam The offset for the results to return.
@param limitParam The max number of results to return.
@param formTypesParam The Id's for the Form Definitions to be returned.

@return The {@code SearchHits} as Fluid {@code Form}.

@see Form
@see SearchHits
Performs a search against the Elasticsearch instance with the { @code qbParam } .