Did anyone ever post a packaged solution for simple field renaming? Since I didn't see one, I offer (link below) a beanshell script 'fieldrename' which uses the Lucene API to run through the segments, gather fieldnames, pass then through a user-supplied regular-expression transformation, and rewrite the .fnm file. For example,
fieldrename /path/to/index ^Abstract$ Summary (renaming of a single field via exact match: Abstract -> Summary) fieldrename /path/to/index Number Code (change substring within every fieldname: ProductNumber -> ProductCode, etc.) It does save the original .fnm files as .fnm.bak just in case, but caveat emptor: Used incorrectly it can destroy a good index in a flash, so always use on a backup index. It works under Lucene 2.2 but has not been tested with 2.3, and it needs a few more lines of code to work with compound-file indexes (which I'd be happy to add if someone were actually interested in using it). FYI I used beanshell rather than Java not only for rapid prototyping, but also because it allows access to a non-public method in the Lucene API. Go wild, J.J. Larrea http://www.nabble.com/file/p15221929/fieldrename fieldrename Andrzej Bialecki wrote: > > [EMAIL PROTECTED] wrote: >> Dear Andrzej Bialecki >> >> Can we change the field name in *.fnm directly by hand? > > Yes, but you need to be consistent about it, i.e. change it the same way > for every segment that the index consists of. Also, fnm files are binary > files, so you need to know the format (unless you preserve the length of > the name, e.g. "secret" -> "public", then you can do it with a binary > editor). > -- View this message in context: http://www.nabble.com/How-to-rename-fields-in-an-index-tp12269902p15221929.html Sent from the Lucene - Java Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]