{"record":{"id":"50634e3f7b7be81a","repo":"NationalSecurityAgency/ghidra","slug":"no-functions-matching-vectorid-50634e","errorCode":null,"errorMessage":"No functions matching vectorid: ","messagePattern":"No functions matching vectorid: ","errorType":"exception","errorClass":"ElasticException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticDatabase.java","lineNumber":958,"sourceCode":"\t\tint count = 0;\n\n\t\tfor (VectorResult dresult : resultset) {\n\t\t\tif (count >= query.max) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tfinal SignatureRecord srec = manager.newSignature(dresult.vec, dresult.hitcount);\n\t\t\tJsonArray descres;\n\t\t\tdescres = queryVectorIdMatch(dresult.vectorid, filter, query.max - count);\n\t\t\tif (descres == null) {\n\t\t\t\tthrow new ElasticException(\n\t\t\t\t\t\"Error querying vectorid: \" + Long.toString(dresult.vectorid));\n\t\t\t}\n\t\t\tif (descres.size() == 0) {\n\t\t\t\tif (filter != null) {\n\t\t\t\t\tcontinue; // Filter may have eliminated all results\n\t\t\t\t}\n\t\t\t\t// Otherwise this is a sign of corruption in the database\n\t\t\t\tthrow new ElasticException(\n\t\t\t\t\t\"No functions matching vectorid: \" + Long.toString(dresult.vectorid));\n\t\t\t}\n\t\t\tcount += descres.size();\n\t\t\tconvertDescriptionRows(similarityResult, descres, dresult, manager, srec);\n\t\t}\n\t}\n\n\t/**\n\t * Perform a full QueryNearest request, with additional filters, placing SimilarityResults\n\t * in the ResponseNearest object. An iterator to FunctionDescriptions determines what\n\t * subset of functions are actually being queried.\n\t * @param query is overarching QueryNearest object\n\t * @param filter is the (optional) additional filters results must pass\n\t * @param response is the ResponseNearest accumulating results\n\t * @param manager is an internal placeholder container primarily for caching ExecutableRecords \n\t * @param iter points to the subset of functions to query\n\t * @return the total number of unique result sets produced by the query\n\t * @throws ElasticException for communication problems with the server","sourceCodeStart":940,"sourceCodeEnd":976,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticDatabase.java#L940-L976","documentation":"Thrown in queryNearest when a vector document was returned by the similarity search but queryVectorIdMatch returns an empty result set (descres.size() == 0) and no filter was applied. The code comment explicitly states this is a sign of database corruption: a vector exists in the repository_vector index but has no corresponding function documents in the executable index.","triggerScenarios":"During queryNearest, for each VectorResult dresult, queryVectorIdMatch issues a term query on id_signature for the vector id. If total==0 it returns an empty JsonArray. With filter==null, hitting an empty result means an orphaned vector document with zero function references.","commonSituations":"Interrupted or partial deletion of an executable that removed function documents but left vector documents behind; interrupted ingestion that wrote vector documents before function documents; concurrent delete operation removing functions while a query is in flight.","solutions":["Re-ingest the affected executable(s) to restore function-to-vector consistency.","Run a diagnostic query to find orphaned vectors: query repository_vector for ids whose id_signature has no matching function documents, then clean them up.","If corruption is widespread, drop and recreate the database from source executables.","Ensure no concurrent ingest or delete operations run during active similarity queries."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    database.query(queryNearest);\n} catch (ElasticException e) {\n    if (e.getMessage().contains(\"No functions matching vectorid\")) {\n        // Orphaned vector — database integrity issue\n        Msg.error(this, \"Orphaned vector detected; re-ingest affected executables or rebuild database: \" + e.getMessage());\n    }\n    throw e;\n}","preventionTips":["Avoid concurrent delete and ingest operations that can leave orphaned vectors.","After bulk deletions, run a consistency check to detect vectors without function references.","If orphaned vectors are found, re-ingest the affected executables to restore referential integrity."],"tags":["elasticsearch","bsim","data-corruption","orphaned-vector","query","data-integrity"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}