{"record":{"id":"9e39ddcc2898a855","repo":"weaviate/weaviate","slug":"inconsistent-results-input-d-neighbors-d","errorCode":null,"errorMessage":"inconsistent results: input=%d neighbors=%d","messagePattern":"inconsistent results: input=(.+?) neighbors=(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/text2vec-contextionary/additional/nearestneighbors/extender.go","lineNumber":87,"sourceCode":"\tif in == nil {\n\t\treturn nil, nil\n\t}\n\n\tvectors := make([][]float32, len(in))\n\tfor i, res := range in {\n\t\tif len(res.Vector) == 0 {\n\t\t\treturn nil, fmt.Errorf(\"item %d has no vector\", i)\n\t\t}\n\t\tvectors[i] = res.Vector\n\t}\n\n\tneighbors, err := e.searcher.MultiNearestWordsByVector(ctx, vectors, DefaultK, limitOrDefault(limit))\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"get neighbors for search results\")\n\t}\n\n\tif len(neighbors) != len(in) {\n\t\treturn nil, fmt.Errorf(\"inconsistent results: input=%d neighbors=%d\", len(in), len(neighbors))\n\t}\n\n\tfor i, res := range in {\n\t\tup := res.AdditionalProperties\n\t\tif up == nil {\n\t\t\tup = models.AdditionalProperties{}\n\t\t}\n\n\t\tup[\"nearestNeighbors\"] = removeDollarElements(neighbors[i])\n\t\tin[i].AdditionalProperties = up\n\t}\n\n\treturn in, nil\n}\n\nfunc NewExtender(searcher contextionary) *Extender {\n\treturn &Extender{searcher: searcher}\n}","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/modules/text2vec-contextionary/additional/nearestneighbors/extender.go#L69-L105","documentation":"After fetching nearest words for every input vector, Multi verifies the search engine returned exactly one neighbor set per input; a mismatch means the contextionary search silently dropped or duplicated results. The error protects downstream per-item assignment from desyncing (wrong neighbors attached to wrong objects).","triggerScenarios":"MultiNearestWordsByVector returns a different number of neighbor groups than the len(in) input results — e.g. internal contextionary index inconsistency, partial failures swallowed upstream, or a searcher implementation not preserving order/count.","commonSituations":"Degraded or reindexed contextionary state, custom searcher implementations, concurrent mutations during large multi-searches.","solutions":["Retry the query — transient index state may resolve it","Check contextionary index health/rebuild it if inconsistent results persist","Report/inspect the searcher implementation to ensure it returns one result group per input vector"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"out, err := extender.Multi(ctx, in, limit)\nif err != nil && strings.Contains(err.Error(), \"inconsistent results\") {\n  out, err = extender.Multi(ctx, in, limit) // retry once\n}","preventionTips":["Keep the contextionary index healthy and rebuild after crashes","Avoid heavy concurrent writes during nearestNeighbors queries","Test custom searcher implementations for 1:1 result counts"],"tags":["go","vectorizer","search","consistency"],"backgroundTag":"inconsistent-search-results","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}