java - How to index date field in lucene -
i new lucene. have index date field. using following indexwriter
constructor in lucene 3.0.0.
indexwriter writer = new indexwriter(fsdirectory.open(indexdir), new whitespaceanalyzer(), true, indexwriter.maxfieldlength.unlimited)
my point is: why needs analyzer when date fields not analyzed,while indexing used field.index.not_analyzed
.
you can store date field in fashion..
document doc = new document(); doc.add(new field("modified", datetools.timetostring(f.lastmodified(), datetools.resolution.minute), field.store.yes, field.index.not_analyzed));
where f file object...
now use above document indexwriter...
checkout sample code comes lucene... , following link... http://lucene.apache.org/java/2_2_0/api/org/apache/lucene/document/datetools.html
update
field.index not_analyzed
index field's value without using analyzer, can searched. no analyzer used value stored single term. useful unique ids product numbers.
as per lucene javadoc don't need analyzer fields using field.index not_analyzed
think design indexwriter
expects analyzer indexing exact replica of data not efficient in terms of storage , searching.
Comments
Post a Comment