Uploaded image for project: 'JIRA Server (including JIRA Core)'
  1. JIRA Server (including JIRA Core)
  2. JRASERVER-3127

failure finding issues by date criteria: org.apache.lucene.search.BooleanQuery$TooManyClauses

    Details

      Description

      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.

      stack trace:

      org.apache.lucene.search.BooleanQuery$TooManyClauses
      at org.apache.lucene.search.BooleanQuery.add(BooleanQuery.java:109)
      at org.apache.lucene.search.BooleanQuery.add(BooleanQuery.java:101)
      at org.apache.lucene.search.RangeQuery.rewrite(RangeQuery.java:137)
      at org.apache.lucene.search.BooleanQuery.rewrite(BooleanQuery.java:244)
      at org.apache.lucene.search.IndexSearcher.rewrite(IndexSearcher.java:188)
      at org.apache.lucene.search.Query.weight(Query.java:120)
      at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:128)
      at org.apache.lucene.search.MultiSearcher.search(MultiSearcher.java:150)
      at org.apache.lucene.search.Hits.getMoreDocs(Hits.java:93)
      at org.apache.lucene.search.Hits.<init>(Hits.java:80)
      at org.apache.lucene.search.Searcher.search(Searcher.java:71)
      at org.apache.lucene.search.Searcher.search(Searcher.java:65)
      at com.atlassian.jira.issue.search.providers.LuceneSearchProvider.search(LuceneSearchProvider.java:75)
      at com.atlassian.jira.issue.search.providers.DefaultSearchProvider.search(DefaultSearchProvider.java:43)
      at com.atlassian.jira.issue.managers.DefaultIssueManager.execute(DefaultIssueManager.java:144)
      at com.atlassian.jira.issue.managers.CachingIssueManager.execute(CachingIssueManager.java:82)
      at com.atlassian.jira.web.action.issue.IssueNavigator.getBrowsableItems(IssueNavigator.java:370)
      at com.atlassian.jira.web.action.issue.IssueNavigator.doExecute(IssueNavigator.java:258)
      at webwork.action.ActionSupport.execute(ActionSupport.java:154)
      at com.atlassian.jira.action.JiraActionSupport.execute(JiraActionSupport.java:46)
      at webwork.dispatcher.GenericDispatcher.executeAction(GenericDispatcher.java:131)
      at com.atlassian.jira.web.dispatcher.JiraServletDispatcher.service(JiraServletDispatcher.java:181)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                anton@atlassian.com Anton Mazkovoi [Atlassian]
                Reporter:
                yo_mama Tim Jones
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 8h
                  8h
                  Remaining:
                  Remaining Estimate - 8h
                  8h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified