IndexReader.open(dir)、IndexWriter(dir)在dir不存在时会先创建,前者创建空dir目录,后者创建带两个索引相关文件
BooleanQuery$TooManyClauses的问题
org.apache.lucene.search.BooleanQuery$TooManyClauses: maxClauseCount is set to 1024
可以通过设置:
BooleanQuery.setMaxClauseCount(10000);
来解决问题,但是这样带来的问题是会使得内存开销加大。容易出现OutOfMemory的异常
所以需要非常谨慎处理
1 楼
caocao 2007-06-22
引用
遇到TooManyClauses一般应从设计角度切入,绝大部分是设计问题。比如rangequery精度太高导致clauses迅速膨胀。
(/// <summary>Set the maximum number of clauses permitted per BooleanQuery.
/// Default value is 1024.
/// <p>TermQuery clauses are generated from for example prefix queries and
/// fuzzy queries. Each TermQuery needs some buffer space during search,
/// so this parameter indirectly controls the maximum buffer requirements for
/// query search.
/// <p>When this parameter becomes a bottleneck for a Query one can use a
/// Filter. For example instead of a {@link RangeQuery} one can use a
/// {@link RangeFilter}.
/// <p>Normally the buffers are allocated by the JVM. When using for example
/// {@link Lucene.Net.Store.MMapDirectory} the buffering is left to
/// the operating system.
/// </summary>
/// Default value is 1024.
/// <p>TermQuery clauses are generated from for example prefix queries and
/// fuzzy queries. Each TermQuery needs some buffer space during search,
/// so this parameter indirectly controls the maximum buffer requirements for
/// query search.
/// <p>When this parameter becomes a bottleneck for a Query one can use a
/// Filter. For example instead of a {@link RangeQuery} one can use a
/// {@link RangeFilter}.
/// <p>Normally the buffers are allocated by the JVM. When using for example
/// {@link Lucene.Net.Store.MMapDirectory} the buffering is left to
/// the operating system.
/// </summary>
public static void SetMaxClauseCount(int maxClauseCount)
)
)