NationalSecurityAgency/ghidra · error · ElasticException

Error querying vectorid

Error message

Error querying vectorid: ${vectorid}

What it means

In the similarity-query path, queryVectorIdMatch for a vector returns null (not an empty array), interpreted as a query-level error rather than 'no matches'. It throws ElasticException("Error querying vectorid: <id>").

Solutions

  1. Retry the query once (often transient).
  2. Check ES cluster health and logs for the failing shard/request.
  3. Re-ingest the affected executable if a specific vector is permanently broken.

Example fix

// before
Response resp = db.query(req); // surfaces opaque 'Error querying vectorid'
// after
Response resp = retryOn(() -> db.query(req), 3, ElasticException.class);
Defensive patterns

Strategy: retry

Validate before calling

// Skip the query if the cluster is unhealthy.
if (!clusterHealthy()) throw new ServiceUnavailableException("Cluster unhealthy");

Try / catch

// Retry transient query failures a bounded number of times.
for (int i = 0; i < 3; i++) {
    try { return db.query(req); }
    catch (ElasticException e) {
        if (i == 2 || !isTransient(e.getMessage())) throw e;
    }
}

Prevention

When it happens

Trigger: A similarity query where fetching function descriptions for a specific vector id fails to yield a usable response (server error, malformed/empty response envelope).

Common situations: Transient ES errors; partial cluster outage; response-shape change after a server upgrade; overloaded cluster timing out one shard.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/e4446baf4276645d. Report an issue: GitHub.

Appendix: source

Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticDatabase.java:3308

		while (iter1.hasNext()) {
			fetchVectors(iter1, iter2, 50);						// Fetch vector associated with each vectorid
		}
		iter1 = vectorList.iterator();
		iter2 = vectorList.iterator();
		while (iter1.hasNext()) {
			fetchVectorCounts(iter1, iter2, MAX_VECTORCOUNT_WINDOW);	// Fetch hitcount of each vector
		}
		int count = 0;
		DescriptionManager manager = query.matchresponse.manage;
		for (VectorResult vecResult : vectorList) {
			if (count >= query.max) {
				break;
			}
			SignatureRecord srec = manager.newSignature(vecResult.vec, vecResult.hitcount);
			JsonArray descres;
			descres = queryVectorIdMatch(vecResult.vectorid, filter, query.max - count);
			if (descres == null) {
				throw new ElasticException(
					"Error querying vectorid: " + Long.toString(vecResult.vectorid));
			}
			if (descres.size() == 0) {
				if (filter != null) {
					continue; // Filter may have eliminated all results
				}
				// Otherwise this is a sign of corruption in the database
				throw new ElasticException(
					"No functions matching vectorid: " + Long.toString(vecResult.vectorid));
			}
			count += descres.size();
			convertDescriptionRows(null, descres, vecResult, manager, srec);
		}
	}

	/**
	 * Entry point for the Elasticsearch version of QueryDelete command:
	 *   Delete specific executables from the database

View on GitHub (pinned to d5f144c24d)