org.apache.lucene.search.BooleanQuery$TooManyClauses: maxClauseCount is set to 1024
at org.apache.lucene.search.BooleanQuery.add(BooleanQuery.java:165)
at org.apache.lucene.search.BooleanQuery.add(BooleanQuery.java:156)
at org.apache.lucene.search.PrefixQuery.rewrite(PrefixQuery.java:53)
at org.apache.lucene.search.BooleanQuery.rewrite(BooleanQuery.java:408)
at org.apache.lucene.search.IndexSearcher.rewrite(IndexSearcher.java:138)
at org.apache.lucene.search.Query.weight(Query.java:94)
at org.apache.lucene.search.Hits.<init>(Hits.java:42)
at org.apache.lucene.search.Searcher.search(Searcher.java:45)
at org.apache.lucene.search.Searcher.search(Searcher.java:37)
at com.toodou.searcher.search.PodcasterSearcher.searchPodcaster(PodcasterSearcher.java:238)
at com.toodou.searcher.search.PodcasterSearcher.doPodcasterSearch(PodcasterSearcher.java:66)
at test.com.toodou.searcher.search.PodcasterSearcherTest.testdoPodcasterSearch(PodcasterSearcherTest.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
可以通过设置:
BooleanQuery.setMaxClauseCount(10000);
来解决问题,但是这样带来的问题是会使得内存开销加大。容易出现OutOfMemory的异常
所以需要非常谨慎处理。