I have to disagree. Nowhere in the javadoc is this condition noted. There is no way for a user to know that this is a restriction, and forcing developers to find this by having a program fail, even with a better error message, is...er...unfortunate. Even if this were in the javadoc, I still have to remember it. And my memory isn't what it used to be....
Optimization where it really doesn't count is, in my experience, bad. Period. I'm making the assumption that setting up the query is a tiny fraction of the time spent in a search. I'm perfectly willing to lose those "very few clockticks" in code that accounts for a tiny, tiny fraction of my search time than I am willing to be surprised by behavior that I have no way of anticipating. And spending the developer/customer/company time chasing such a problem down. So the notion of a library forcing me to optimize where *the library writers* think I should raises a red flag right away. Of course it's a balancing act. I'd also not like the library to get so concerned with being idiot-proof that it gets noticeably slower. Given all the time and energy that I expect Lucene to save me, I'm content to let the Lucene folks make that determination. They are in a far better place to judge whether this would be worth it or not. So, I'll put in the bug report and be happy with whatever decision is made by the Lucene folks. As you can probably tell, I've spent faaaarrrr too much of my professional life looking at code that was efficient, complicated, and wrong in some subtle or not-so-subtle way and caused failures of one sort or another. And improved execution time by, say, .0001%. I don't accept the efficiency argument unless it can be shown to matter. The eXtreme Programming folks have it right, "Make it work, make it right, make it fast". I'd change it a bit to "make it fast if it matters". Those times it has mattered, my guesses as to where the time was being wasted have been wrong most of the time. Ok, now you know where one of my buttons is. I'll get off my soap-box now... Erick P.S. I'll be glad to exchange a few e-mail with you if you want to try to persuade me. We probably shouldn't turn this into a philosophical debate over optimization, since it *is* a Lucene forum.......