private Optional<ErrorMessage> validate(Query query) {
        NNVisitor visitor = new NNVisitor(query.getRanking().getProperties(), validAttributes, query);
        ToolBox.visit(visitor, query.getModel().getQueryTree().getRoot());
        return visitor.errorMessage;
    }
Validates any NearestNeighborItem query items.

@author arnej
container-search/src/main/java/com/yahoo/search/searchers/ValidateNearestNeighborSearcher.java