lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Neil Prosser <>
Subject Solr QueryResultKey hashCode() and equals()
Date Wed, 17 Aug 2011 21:24:24 GMT
Hi there,

Hopefully I'm not misunderstanding the situation but after playing around
with cache warming in Solr I found that the order of the Query objects
within the filters list makes a difference to the equals() and hashCode()

Query query = new TermQuery(new Term("field1", "value1"));
Query filter1 = new TermQuery(new Term("field2", "value2"));
Query filter2 = new TermQuery(new Term("field3", "value3"));
 List<Query> filters1 = new ArrayList<Query>();
 List<Query> filters2 = new ArrayList<Query>();
 QueryResultKey key1 = new QueryResultKey(query, filters1, null, 0);
QueryResultKey key2 = new QueryResultKey(query, filters2, null, 0);
 // Both the following assertions fail
assert key1.equals(key2);
assert key1.hashCode() == key2.hashCode();

I found that it resulted in a cache miss for two queries that have the same
results just because the filters had a different ordering. Am I missing
something or is there an opportunity to improve the chance of matching cache

View raw message