【问题标题】:How to tweak lucene maxClauseCount from Neo4j?如何从 Neo4j 调整 lucene maxClauseCount?
【发布时间】:2013-09-07 18:37:20
【问题描述】:

以下是我们的按 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

我们在堆栈跟踪中看到:ma​​xClauseCount 设置为 1024

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

【问题讨论】:

  • 这可能令人望而却步。你的用例是什么?
  • 一个外部系统根据规则选出一群病人。然后它在 1 次往返中从 neo4j 中查询有关这些患者的某些信息。
  • 我认为,如果您不使用基于 Java 的 Cypher,那就更令人望而却步了。
  • 我是 Neo4j 的新手。我唯一的要求是在 1 次往返中获取多个患者的信息。我们在旧版 Oracle 服务中有一个 IN sql

标签: java performance lucene neo4j cypher


【解决方案1】:

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

BooleanQuery.setMaxClauseCount(20000);

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

【讨论】:

  • 您可能会遇到其他问题,而且会更高,但如果 3000 对您的所有用例都足够好,那么您可能没问题。您的患者规则能否为您提供无限数量的患者?
  • 如果整个图都在内存中,即我们有足够大的堆...... lucene 还能爆炸吗?
  • 我认为您正在为自己铺平道路——至少我从未尝试过。 :)
  • 我也有不好的预感:)
【解决方案2】:

试试这个(未经测试):

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

【讨论】:

  • 它不起作用:(我们使用的是使用 Lucene 3.6.2 的 Neo 1.9.3
  • 很高兴知道。我会把它留给后代。
猜你喜欢
  • 2012-09-28
  • 1970-01-01
  • 2014-12-03
  • 1970-01-01
  • 2019-05-04
  • 1970-01-01
  • 2013-05-10
  • 1970-01-01
  • 2015-06-20
相关资源
最近更新 更多