private long fetchVectorCounts(Iterator<VectorResult> iter1, Iterator<VectorResult> iter2,
			int maxDocuments) throws ElasticException {
		if (!iter1.hasNext()) {
			return 0;
		}
		long totalCount = 0;
		VectorResult vecRes = iter1.next();
		StringBuilder buffer = new StringBuilder();
		// append the first id
		buffer.append("{ \"ids\": [ ");
		buffer.append('\"');
		Base64Lite.encodeLongBase64(buffer, vecRes.vectorid);
		buffer.append('\"');
		for (int i = 1; i < maxDocuments; ++i) {
			if (!iter1.hasNext()) {
				break;
			}
			vecRes = iter1.next();
			buffer.append(", \"");
			Base64Lite.encodeLongBase64(buffer, vecRes.vectorid);
			buffer.append('\"');
		}
		buffer.append(" ] }");
		JsonObject resp =
			connection.executeStatement(ElasticConnection.GET, "meta/_mget", buffer.toString());
		JsonArray docs = (JsonArray) resp.get("docs");
		for (int i = 0; i < maxDocuments; ++i) {
			if (!iter2.hasNext()) {
				break;
			}
			vecRes = iter2.next();
			JsonObject oneResp = (JsonObject) docs.get(i);
			String matchId = oneResp.get("_id").getAsString();
			long matchIdVal = Base64Lite.decodeLongBase64(matchId);
			if (matchIdVal != vecRes.vectorid) {
				throw new ElasticException("Mismatch in metaid");
			}
			JsonElement source = oneResp.get("_source");
			if (ElasticConnection.isNull(source)) {
				throw new ElasticException("meta document does not exist for id=" + matchId);
			}
			long count = ((JsonObject) source).get("count").getAsLong();
			totalCount += count;
			vecRes.hitcount = (int) count;
		}
		return totalCount;
	}
Fill in hitcounts for a list of VectorResults by querying for the meta document that
matches the vector id. The meta documents are queried in bulk up to a maximum number.
Two iterators pointing to the same list of VectorResults must be supplied. One is
used to generate the bulk query document. The second is used to fill in the hitcount
field from the resulting meta documents. If no exception is thrown, both iterators
will be advanced the same number of times.
@param iter1 is the iterator to VectorResults to fill in
@param iter2 is a copy of the first iterator
@param maxDocuments is the maximum number of documents to query for
@return the total number of function matching the vectors queried
@throws ElasticException for communication problems with the server
Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticDatabase.java