« Adding a new field to the dspace database | Main | Add a user to a group »

Make a Lucene field sortable and searchable

The java code snippet below will add searchable (TOKENIZED) fields and
sortable (UN_TOKENIZED) fields to a Lucene document.


if (value != null)
{
doc.add(new Field(key, value, Field.Store.YES, Field.Index.TOKENIZED));
if (key.equalsIgnoreCase("author") || key.equalsIgnoreCase("title") || key.equalsIgnoreCase("date") )
{
doc.add(new Field(key + "_sortable", value, Field.Store.YES, Field.Index.UN_TOKENIZED));

}
}


This is from the ag econ project file:

./src/org/dspace/search/DSIndexer.java

TrackBack

TrackBack URL for this entry:
http://blog.lib.umn.edu/cgi-bin/mt-tb.cgi/53784

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)