when there are a large number of issues spanning a large number of dates in Jira, searches using date criteria will fail with the exception:
An error occurred searching: org.apache.lucene.search.BooleanQuery$TooManyClauses
see stack trace below.
The problem is that the date range search query actually turns into a BooleanQuery inside lucene, and if there are more than 1024 different dates, lucene will fail.
What needs to happen is the "Created After" and "Created Before" search criteria need to be combined into a single date range. Right now, they are individual RangeQueries, causing lucene to try to match every single date on one side or the other of the chosen boundary.
If the user only chooses "Created Before" (for example), and there are more than 1000 possible dates, Jira should present some kind of error message asking for a lower limit. Or (perhaps better) go as far as it can and report the limit in the search results.
Note that the lucene api allows you to retrieve terms less than a given term - see IndexReader#terms(Term). It would be possible to use this to determine that too many dates match.
Another solution would be to "normalize" dates in the search index to whole number days only. Right now it would appear the actual timestamp is indexed and the hours, minutes and seconds are not stripped off. Stripping these off would reduce the number of indexed terms in the lucene index. However, after a few years (1024 days, to be exact even this will fail - so Jira will still need to do some error checking.