Allow to raise BooleanQuery limit in gerrit.config.

Raising the limit avoids failing a query BooleanQuery.TooManyClauses,
preventing users from seeing "400 cannot create query for index" error
in the "Conflicts with" part of the change screen.

Change-Id: Ie0bf14c4a3e6c4833c064f7ac822c08aa2aaffb8
This commit is contained in:
Olga Grinberg 2014-10-15 08:37:23 -04:00 committed by David Pursehouse
parent c99289b27d
commit 74ccc23d02
2 changed files with 13 additions and 0 deletions

View File

@ -1927,6 +1927,14 @@ Only used when the type is `SOLR`.
+
URL of the index server.
[[index.defaultMaxClauseCount]]index.defaultMaxClauseCount::
+
Only used when the type is `LUCENE`.
+
Sets the maximum number of clauses permitted per BooleanQuery.
+
Defaults to 1024.
[[index.name.ramBufferSize]]index.name.ramBufferSize::
+
Only used when the type is `LUCENE`.
@ -1976,6 +1984,7 @@ Sample index configuration:
----
[index]
type = LUCENE
defaultMaxClauseCount = 2048
[index "changes_open"]
ramBufferSize = 60 m

View File

@ -73,6 +73,7 @@ import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
@ -228,6 +229,9 @@ public class LuceneChangeIndex implements ChangeIndex {
new StandardAnalyzer(luceneVersion, CharArraySet.EMPTY_SET);
queryBuilder = new QueryBuilder(schema, analyzer);
BooleanQuery.setMaxClauseCount(cfg.getInt("index", "defaultMaxClauseCount",
BooleanQuery.getMaxClauseCount()));
GerritIndexWriterConfig openConfig =
new GerritIndexWriterConfig(luceneVersion, cfg, "changes_open");
GerritIndexWriterConfig closedConfig =