TermsQuery inherits the default impl of extractTerms which throws an UnsupportedOperationException.
I think it should be abstract in Query. The UOE was only added in Lucene 1.x or 2.x for backwards compatibility reasons
I actually think it should. I know how people abuse this query and do not think we should implement an unbounded extractTerms. UOE is much better.
Uwe: I was also wondering that it might make sense to move this method to Weight so that we only have to implement it for core queries and not those that always rewrite to a different query? (extractTerms documentation states it only makes sense on rewritten queries)
Robert: The issue is that it fails term extraction for the whole query even if this query is only used for filtering. Maybe we could make extractTerms a no-op on TermsQuery and then it would behave just like when this query was still only a filter?
Here is a proposal: it makes TermsQuery.extractTerms a no-op.
We should also fix the javadocs of this class? Now that its a query, its very confusing.
It should mention that it does not score, maybe with an example like:
This is equivalent to a ConstantScoreQuery(BooleanQuery(x, y, z), 1F) but potentially more efficient.
Same patch with improved javadocs, does it look better?
Commit 1673118 from Adrien Grand in branch 'dev/trunk'
[ https://svn.apache.org/r1673118 ]
LUCENE-6415: Make TermsQuery.extractTerms a no-op instead of throwing an UOE.
Commit 1673119 from Adrien Grand in branch 'dev/branches/branch_5x'
[ https://svn.apache.org/r1673119 ]
Bulk close for 5.2.0.