You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Keith Rhodes <kr...@yahoo.com> on 2007/10/27 08:11:25 UTC

Adding and populating a field

I have a set of documents with filenames that give a good indication of content.

A filename of 12 digits (I think this is [0-9]{12} as a regular expression) with the extension html is a troubleshooting guide, the number being an error code.
A filename with two or three letters, then a minus (which would be [a-z]{2,3}- I think), then a known string means the document is about a particular subject; I have a list of the known strings matched to subjects.

What I would like to do, is have my indexer create a field named "category", populated with either the string "troubleshooting" or with the known string extracted from the filename.

Examples:
For a file named 0000000000111.html the indexer adds the field "category" with the value "troubleshooting".
For a file named xxx-cal-123.html the indexer adds the field "category" with the value "cal".
For a file named xx-qv-(9).html the indexer adds the field "category" with the value "qv".

Is there a way to do that?
 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: Adding and populating a field

Posted by Erick Erickson <er...@gmail.com>.
no automatic way, you to do it yourself. Presumably, you have
some master list of categories that you can map your file
names to, so as you index each file you have to look up the
category and add it to the document you are about to index.

Best
Erick

On 10/27/07, Keith Rhodes <kr...@yahoo.com> wrote:
>
> I have a set of documents with filenames that give a good indication of
> content.
>
> A filename of 12 digits (I think this is [0-9]{12} as a regular
> expression) with the extension html is a troubleshooting guide, the number
> being an error code.
> A filename with two or three letters, then a minus (which would be
> [a-z]{2,3}- I think), then a known string means the document is about a
> particular subject; I have a list of the known strings matched to subjects.
>
> What I would like to do, is have my indexer create a field named
> "category", populated with either the string "troubleshooting" or with the
> known string extracted from the filename.
>
> Examples:
> For a file named 0000000000111.html the indexer adds the field "category"
> with the value "troubleshooting".
> For a file named xxx-cal-123.html the indexer adds the field "category"
> with the value "cal".
> For a file named xx-qv-(9).html the indexer adds the field "category" with
> the value "qv".
>
> Is there a way to do that?
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com