如何从Neo4j调整lucene maxClauseCount?

时间:2013-09-07 18:37:20

标签: java performance lucene neo4j cypher

以下是我们通过ID服务查找的密码:

START n=node:PATIENTS('MEMBER_PLAN_ID:(1 2)') return n

其中1 2是通过的ID。当我们在发生错误时传递大约2000个ID:

java.lang.RuntimeException: org.apache.lucene.queryParser.ParseException: Cannot parse 'MEMBER_PLAN_ID:(1 2)': too many boolean clauses
        at org.neo4j.index.impl.lucene.IndexType.query(IndexType.java:304)
        at org.neo4j.index.impl.lucene.LuceneIndex.query(LuceneIndex.java:227)
        at org.neo4j.index.impl.lucene.LuceneIndex.query(LuceneIndex.java:238)
        at org.neo4j.cypher.internal.spi.gdsimpl.GDSBackedQueryContext$$anon$1.indexQuery(GDSBackedQueryContext.scala:87)
        at org.neo4j.cypher.internal.executionplan.builders.IndexQueryBuilder$$anonfun$getNodeGetter$2.apply(IndexQueryBuilder.scala:83)
        at org.neo4j.cypher.internal.executionplan.builders.IndexQueryBuilder$$anonfun$getNodeGetter$2.apply(IndexQueryBuilder.scala:81)
        at org.neo4j.cypher.internal.pipes.StartPipe$$anonfun$internalCreateResults$1.apply(StartPipe.scala:36)
        at org.neo4j.cypher.internal.pipes.StartPipe$$anonfun$internalCreateResults$1.apply(StartPipe.scala:35)
        at scala.collection.Iterator$$anon$13.__AW_hasNext(Iterator.scala:371)
        at scala.collection.Iterator$$anon$13.hasNext(Iterator.scala)
        at org.neo4j.cypher.internal.ClosingIterator$$anonfun$hasNext$1.apply$mcZ$sp(ClosingIterator.scala:36)
        at org.neo4j.cypher.internal.ClosingIterator$$anonfun$hasNext$1.apply(ClosingIterator.scala:35)
        at org.neo4j.cypher.internal.ClosingIterator$$anonfun$hasNext$1.apply(ClosingIterator.scala:35)
        at org.neo4j.cypher.internal.ClosingIterator.failIfThrows(ClosingIterator.scala:86)
        at org.neo4j.cypher.internal.ClosingIterator.hasNext(ClosingIterator.scala:35)
        at org.neo4j.cypher.PipeExecutionResult.hasNext(PipeExecutionResult.scala:157)
        at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:327)
        at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:327)
        at scala.collection.convert.Wrappers$IteratorWrapper.hasNext(Wrappers.scala:29)
        at org.neo4j.cypher.PipeExecutionResult$$anon$1.hasNext(PipeExecutionResult.scala:73)
        at net.ahm.graph.dao.PatientDAO.__AW_findPatients(PatientDAO.java:376)


Caused by: org.apache.lucene.queryParser.ParseException: Cannot parse 'MEMBER_PLAN_ID:(1 2)': too many boolean clauses
        at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:221)
        at org.neo4j.index.impl.lucene.IndexType.query(IndexType.java:300)
        ... 38 more
Caused by: org.apache.lucene.search.BooleanQuery$TooManyClauses: maxClauseCount is set to 1024
        at org.apache.lucene.search.BooleanQuery.add(BooleanQuery.java:136)
        at org.apache.lucene.queryParser.QueryParser.getBooleanQuery(QueryParser.java:958)
        at org.apache.lucene.queryParser.QueryParser.getBooleanQuery(QueryParser.java:933)
        at org.apache.lucene.queryParser.QueryParser.Query(QueryParser.java:1281)
        at org.apache.lucene.queryParser.QueryParser.Clause(QueryParser.java:1323)
        at org.apache.lucene.queryParser.QueryParser.Query(QueryParser.java:1245)
        at org.apache.lucene.queryParser.QueryParser.TopLevelQuery(QueryParser.java:1234)
        at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:206)
        ... 39 more

我们在堆栈跟踪中看到这一点: maxClauseCount设置为1024

有没有办法在使用Cypher时从Neo4j配置此限制?

2 个答案:

答案 0 :(得分:3)

但是,如果我将此行添加到我们的服务中,一切正常:

BooleanQuery.setMaxClauseCount(20000);

我们进行了一些负载测试,其中1000个并发用户每次点击10,000个ID。之后没有看到服务崩溃/任何意外的性能问题。

答案 1 :(得分:-1)

试试这个(未经测试):

System.setProperty("org.apache.lucene.maxClauseCount", "3000");