private int queryFunctions(QueryNearest query, String filter, ResponseNearest response,
			DescriptionManager manager, Iterator<FunctionDescription> iter)
			throws ElasticException, LSHException {

		// Keep a map of the feature vectors and their query results; if we have vectors that
		// are of equal value, we'll just query the first one, and use those results for the
		// others.
		HashMap<LSHVector, List<VectorResult>> vecToResultMap = new HashMap<>();

		while (iter.hasNext()) {
			final FunctionDescription frec = iter.next();
			final SignatureRecord srec = frec.getSignatureRecord();

			if (srec == null) {
				continue;
			}
			final LSHVector thevec = srec.getLSHVector();
			final double len2 = vectorFactory.getSelfSignificance(thevec);

			// Self significance should be bigger than the significance threshold
			// (or its impossible our result can exceed the threshold)
			if (len2 < query.signifthresh) {
				continue;
			}
			response.totalfunc += 1;
			final SimilarityResult simres = new SimilarityResult(frec);
			if (manager.getExecutableRecordSet().size() > 1000) {
				manager.clear();
			}
			else {
				// Try to preserve ExecutableRecords so we don't have to connect every time 
				manager.clearFunctions();
			}
			queryNearest(simres, manager, thevec, query, filter, vecToResultMap);
			if (simres.size() == 0) {
				continue;
			}
			response.totalmatch += 1;
			if (simres.size() == 1) {
				response.uniquematch += 1;
			}

			response.result.add(simres);

			simres.transfer(response.manage, true);
		}

		return vecToResultMap.size();
	}
Perform a full QueryNearest request, with additional filters, placing SimilarityResults
in the ResponseNearest object. An iterator to FunctionDescriptions determines what
subset of functions are actually being queried.
@param query is overarching QueryNearest object
@param filter is the (optional) additional filters results must pass
@param response is the ResponseNearest accumulating results
@param manager is an internal placeholder container primarily for caching ExecutableRecords 
@param iter points to the subset of functions to query
@return the total number of unique result sets produced by the query
@throws ElasticException for communication problems with the server
@throws LSHException for problems adding new records to the response
Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticDatabase.java