Date: 2005-01-03T13:14:36 Editor: DanielNaber Wiki: Jakarta Lucene Wiki Page: LuceneFAQ URL: http://wiki.apache.org/jakarta-lucene/LuceneFAQ
new item about toomanyclauses exception Change Log: ------------------------------------------------------------------------------ @@ -89,6 +89,26 @@ * Use the Query's toString() method to see how it actually got parsed. * Use [http://www.getopt.org/luke/ Luke] to browse your index. + +==== Why am I getting a TooManyClauses exception? ==== + +The following types of queries are expanded by Lucene before it does the search: !RangeQuery, +!PrefixQuery, !WildcardQuery, !FuzzyQuery. For example, if the indexed document contain the terms "car" +and "cars" the query "ca*" will be expanded to "car OR cars" before the search takes place. The +number of these terms is limited to 1000 be default. Here's what you can do to avoid the +!TooManyClauses exception: + + * Use a filter that restricts the query. For example, a !DateFilter can replace a !RangeQuery on date + fields and it will never throw the !TooManyClauses exception. Note that filters are slower than + queries when used for the first time, so you chould cache them using + [http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/search/CachingWrapperFilter.html CachingWrapperFilter]. + * If the problem occurs with !RangeQuery, try to reduce the number of terms in the index. For + example, the !DateField class uses a microsecond resultion, which is often not required. Instead you + can save your dates in the "yyyymmddHHMM" format, maybe even without hours and minutes if you don't + need them (this will be simplified in Lucene 2.0 thanks to the new !DateTools class). + * Increase the number of terms using [http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/search/BooleanQuery.html#setMaxClauseCount(int) BooleanQuery.setMaxClauseCount()]. Note that this will increase the memory requirements for searches that expand to many terms. To deactivate any limits, use !BooleanQuery.setMaxClauseCount(Integer.MAX_VALUE). + + ==== What wildcard search support is available from Lucene? ==== Lucene supports wild card queries which allow you to perform searches such as ''book*'', which will find documents containing terms such as ''book'', ''bookstore'', ''booklet'', etc. Lucene refers to this type of a query as a 'prefix query'. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]