Mutable queries are an issue for automatic filter caching since modifying a query after it has been put into the cache will corrupt the cache. We should make all queries immutable (up to the boost) to avoid this issue.
Since they are part of the public API I would suggest splitting them in an immutable class and a builder like was done for most other Queries before releasing an official 6.x version
I did a quick scan through all derived classes of Query and I compiled the following list (ignoring sources in test or contrib folders)
Some of them are already marked as experimental (but should perhaps receive the "official" @lucene.experimental tag ?)
For some it's possibly not an issue since they should never end up in a filter cache (like MoreLikeThisQuery ?), but then a comment specifying the exception to the rule should perhaps be added.
- org.apache.lucene.queries.CustomScoreQuery (marked as @lucene.experimental)
- org.apache.lucene.search.suggest.document.ContextQuery (marked as @lucene.experimental)
- org.apache.lucene.facet.DrillDownQuery (marked as @lucene.experimental)