diff --git a/include/opendht/indexation/pht.h b/include/opendht/indexation/pht.h
index 92328703eed97fa0914b963eb0d37a154fc7e6ee..23d5a5fa9b2d890940acc8f0e1e523553038c551 100644
--- a/include/opendht/indexation/pht.h
+++ b/include/opendht/indexation/pht.h
@@ -246,7 +246,7 @@ private:
         return k.size() == keySpec_.size() and
             std::equal(k.begin(), k.end(), keySpec_.begin(),
                 [&](const Key::value_type& key, const KeySpec::value_type& key_spec) {
-                    return key.first == key_spec.first;
+                    return key.first == key_spec.first and key.second.size() <= key_spec.second;
                 }
             );
     }