[
https://issues.apache.org/jira/browse/LUCENE-6661?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14615703#comment-14615703
]
Adrien Grand commented on LUCENE-6661:
--------------------------------------
One issue I have with marker interfaces is that they do not support wrapping.
Eg. if you put such a query in a BooleanQuery, then the BooleanQuery would be
considered cacheable although it should not be cached either.
One way to work around this issue would be to make a query that is not equal to
any other query but itself? Eg:
{code}
class MyQuery extends Query {
private Object identity = null;
boolean equals(Object o) {
if (super.equals(o) == false) {
return false;
}
MyQuery that = (MyQuery) o;
return identity == that.identity;
}
int hashcode() {
return 31 * super.hashcode() + Objects.hashcode(identity);
}
Weight createWeight(IndexSearcher searcher, boolean needsScores) {
// create a query that will be equal to no other query
// given that we use Weight.getQuery() for caching
Query weightQuery = clone();
weightQuery.identity = new Object();
return new Weight(weightQuery) {
// weight impl
};
}
}
{code}
Given that the cache only caches queries that are reused, it will never be
cached.
> Allow queries to opt out of caching
> -----------------------------------
>
> Key: LUCENE-6661
> URL: https://issues.apache.org/jira/browse/LUCENE-6661
> Project: Lucene - Core
> Issue Type: Improvement
> Affects Versions: 5.2
> Reporter: Terry Smith
> Priority: Minor
> Attachments: LUCENE-6661.patch
>
>
> Some queries have out-of-band dependencies that make them incompatible with
> caching, it'd be great if they could opt out of the new fancy query/filter
> cache in IndexSearcher.
> This affects DrillSidewaysQuery and any user-provided custom Query
> implementations.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]