|
Size: 1299
Comment:
|
← Revision 5 as of 2009-09-20 21:47:57 ⇥
Size: 1315
Comment: converted to 1.6 markup
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 1: | Line 1: |
| If only year, month, day are relevant to your situation, index the text string "YYYYMMDD" as [http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/document/Field.html#Keyword(java.lang.String,%20java.lang.String) Field.Keyword(String, String)], rather than using [http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/document/DateField.html DateField] or [http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/document/Field.html#Keyword(java.lang.String,%20java.util.Date) Field.Keyword(String, Date)]. Why? Because [http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/search/RangeQuery.html RangeQuery] will expand into a [http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/search/BooleanQuery.html BooleanQuery] of all terms in the range, and [http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/document/DateField.html DateField] represents down to the millisecond level and can expand into more terms than are allowed in a [http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/search/BooleanQuery.html BooleanQuery]. | If only year, month, day are relevant to your situation, index the text string "YYYYMMDD" as [[http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/document/Field.html#Keyword(java.lang.String,%20java.lang.String)|Field.Keyword(String, String)]], rather than using [[http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/document/DateField.html|DateField]] or [[http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/document/Field.html#Keyword(java.lang.String,%20java.util.Date)|Field.Keyword(String, Date)]]. Why? Because [[http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/search/RangeQuery.html|RangeQuery]] will expand into a [[http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/search/BooleanQuery.html|BooleanQuery]] of all terms in the range, and [[http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/document/DateField.html|DateField]] represents down to the millisecond level and can expand into more terms than are allowed in a [[http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/search/BooleanQuery.html|BooleanQuery]]. |
| Line 3: | Line 3: |
| Another reason to do this is that you will be able to index dates before the Unix Epoch (Jan 1, 1970) which [http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/document/DateField.html DateField] cannot handle. | Another reason to do this is that you will be able to index dates before the Unix Epoch (Jan 1, 1970) which [[http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/document/DateField.html|DateField]] cannot handle. |
If only year, month, day are relevant to your situation, index the text string "YYYYMMDD" as Field.Keyword(String, String), rather than using DateField or Field.Keyword(String, Date). Why? Because RangeQuery will expand into a BooleanQuery of all terms in the range, and DateField represents down to the millisecond level and can expand into more terms than are allowed in a BooleanQuery.
Another reason to do this is that you will be able to index dates before the Unix Epoch (Jan 1, 1970) which DateField cannot handle.