Here the patch:
1. There are some changes to FilterTermEnum in core:
- Make the private members protected, to have access to them from the very special TrieRangeTermEnum
- Fix a small inconsistency (docFreq() now only returns a value, if a valid term is existing)
- All core tests pass
2. TrieRange patch:
- New TrieRangeQuery classes
- TrieRangeFilter is now only a wrapper (like in core)
- The work is done in package-private TrieRangeTermEnum. This was really a fun to implement this: It started with a very large and complicated version that got simplier and simplier at the end. I am really happy with it now. Maybe a extra test for the "special cases" should be added
Some additional comments:
The functions that return the unique term count hit during executing query/filter is implemented as a counter in the enum that counts all valid terms in termCompare(). Maybe this information is also interesting for other MultiTermQueries. How about counting this directly in MultiTermQuery for all such queries and export the method there? It would be really nice, to get e.g. the number of terms for a classical range query, to see the improvement. I could patch the MultiTermQuery to do this internally. Any comments about that?
The package and class names are still contrib-like as before. A move to core would rename the classes as discussed.