Hello,
I have encountered an issue that the KnnFloatVectorQuery could not get the
superset from queryResultCache when I have negative filters in the request.
For example, *fq=-some_field:value*. But with positive fq it works fine:
*fq=**some_field**:value*
Here is my testing environment:
Solr 9.5.0
openjdk 21.0.9 2025-10-21
OpenJDK Runtime Environment (build 21.0.9+10-Ubuntu-122.04)
OpenJDK 64-Bit Server VM (build 21.0.9+10-Ubuntu-122.04, mixed mode,
sharing)
I think it's probably because of the hashCode() function in DocSetQuery
class. The query result cache uses QueryResultKey which relies on the
query.hashCode() value, however, AbstractKnnVectorQuery's hashcode function
uses the hashcode values from the vector field, k, and the prefilter query:
@Override
public int hashCode() {
return Objects.hash(field, k, filter);
}
The prefilter queries are converted to DocSetQuery object whose
underlying DocSet object may not implement the hashCode() function, such
as BitDocSet or SortedIntDocSet, hence KnnFloatVectorQuery.hashcode() value
may not be consistent, depending on the JVM. In my test
setting, SortedIntDocSet(positive fq) seems getting consistent hashcode
value but not BitDocSet(negative fq). I'm wondering if anyone else has seen
this issue?
Thanks in advance,
Yue