private String validate(NearestNeighborItem item) {
            if (item.getTargetNumHits() < 1)
                return item + " has invalid targetHits " + item.getTargetNumHits() + ": Must be >= 1";

            String queryFeatureName = "query(" + item.getQueryTensorName() + ")";
            Optional<Tensor> queryTensor = query.getRanking().getFeatures().getTensor(queryFeatureName);
            if (queryTensor.isEmpty())
                return item + " requires a tensor rank feature named '" + queryFeatureName + "' but this is not present";

            if (badQueryTensorType(queryTensor.get().type())) {
                return item + " tensor " + queryFeatureName + " must have exactly 1, indexed dimension, but was: " + queryTensor.get().type();
            }
            if ( ! validAttributes.containsKey(item.getIndexName())) {
                return item + " field is not an attribute";
            }
            List<TensorType> allTensorTypes = validAttributes.get(item.getIndexName());
            for (TensorType fieldType : allTensorTypes) {
                if (isTensorTypeThatSupportsHnswIndex(fieldType) && isCompatible(fieldType, queryTensor.get().type())) {
                    return null;
                }
            }
            for (TensorType fieldType : allTensorTypes) {
                if (isTensorTypeThatSupportsHnswIndex(fieldType) && ! isCompatible(fieldType, queryTensor.get().type())) {
                    return item + " field type " + fieldType + " does not match query type " + queryTensor.get().type();
                }
            }
            for (TensorType fieldType : allTensorTypes) {
                if (! isTensorTypeThatSupportsHnswIndex(fieldType)) {
                    return item + " field type " + fieldType + " is not supported by nearest neighbor searcher";
                }
            }
            return item + " field is not a tensor";
        }
Returns an error message if this is invalid, or null if it is valid
container-search/src/main/java/com/yahoo/search/searchers/ValidateNearestNeighborSearcher.java