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 George Aroush <ge...@aroush.net> on 2007/08/30 04:03:27 UTC

Can a Lucene field be renamed in a Lucene index?

Hi everyone,

I have the following need and I wander what are my options or if anyone run
into it and has a solution / suggestion.

I'm indexing a SQL database.  Each table is a Lucene index.  Now, in table
"A", I have a field called "Foo".  When I index it into Lucene, I also end
up with a field called "Foo".  Later on, the SQL database administrator,
will change the field name from "Foo" to "Bar".  Once this happens, any new
records added to table "A" will be indexed into Lucene as "Bar".

The issue is this, Lucene index for table "A" now has documents with some
having a field called "Foo" and others with "Bar".  This is problematic
because now a user can't just search for "Foo:dog", but must search for
"Foo:dog Bar:dog".

So, what are my options here?  No, I can't re-index.  Ideally, I would like
to be able to say to Lucene, "rename the field 'Foo' to 'Bar' in the index
'A'" (even if it means using private APIs).  Is this possible?  Have you run
into this problem?  What was your solution?

Regards,

-- George


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Can a Lucene field be renamed in a Lucene index?

Posted by Chris Lu <ch...@gmail.com>.
The easiest solution would be to change the SQL to
 select Bar as Foo, ..., from your_table

Use an alias and maintain everything as before.

If it's not a solution, you may need to re-index everything.

-- 
Chris Lu
-------------------------
Instant Scalable Full-Text Search On Any Database/Application
site: http://www.dbsight.net
demo: http://search.dbsight.com
Lucene Database Search in 3 minutes:
http://wiki.dbsight.com/index.php?title=Create_Lucene_Database_Search_in_3_minutes

On 8/29/07, George Aroush <ge...@aroush.net> wrote:
>
> Hi everyone,
>
> I have the following need and I wander what are my options or if anyone
> run
> into it and has a solution / suggestion.
>
> I'm indexing a SQL database.  Each table is a Lucene index.  Now, in table
> "A", I have a field called "Foo".  When I index it into Lucene, I also end
> up with a field called "Foo".  Later on, the SQL database administrator,
> will change the field name from "Foo" to "Bar".  Once this happens, any
> new
> records added to table "A" will be indexed into Lucene as "Bar".
>
> The issue is this, Lucene index for table "A" now has documents with some
> having a field called "Foo" and others with "Bar".  This is problematic
> because now a user can't just search for "Foo:dog", but must search for
> "Foo:dog Bar:dog".
>
> So, what are my options here?  No, I can't re-index.  Ideally, I would
> like
> to be able to say to Lucene, "rename the field 'Foo' to 'Bar' in the index
> 'A'" (even if it means using private APIs).  Is this possible?  Have you
> run
> into this problem?  What was your solution?
>
> Regards,
>
> -- George
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: Can a Lucene field be renamed in a Lucene index?

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Aug 29, 2007, at 10:33 PM, George Aroush wrote:
> Just read the thread.  Unfortunately, it doesn't offer a solution.

As I read it offered a number of solutions:

   * Twiddle the *.fnm files (carefully)

   * Use string substitution on the users query, so "foo:whatever" ->  
"bar:whatever" under the covers

   * Wrap IndexReader


> Is it possible to write a tool that will read the source index, and  
> write it
> to an output index with the field renamed?  No, the raw-text is not  
> stored
> in the Lucene index.

Effectively that process would only be changing the *.fnm files as  
mentioned in that thread.

	Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


RE: Can a Lucene field be renamed in a Lucene index?

Posted by George Aroush <ge...@aroush.net>.
Just read the thread.  Unfortunately, it doesn't offer a solution.

Is it possible to write a tool that will read the source index, and write it
to an output index with the field renamed?  No, the raw-text is not stored
in the Lucene index.

Thanks.

-- George

> -----Original Message-----
> From: Erik Hatcher [mailto:erik@ehatchersolutions.com] 
> Sent: Wednesday, August 29, 2007 10:10 PM
> To: java-user@lucene.apache.org
> Subject: Re: Can a Lucene field be renamed in a Lucene index?
> 
> there was just this thread here recently:
> 
>    <http://www.nabble.com/How-to-rename-fields-in-an-index-
> tf4310043.html#a12269902>
> 
> hope that helps.
> 
> 	Erik
> 
> 
> On Aug 29, 2007, at 10:03 PM, George Aroush wrote:
> 
> > Hi everyone,
> >
> > I have the following need and I wander what are my options or if 
> > anyone run into it and has a solution / suggestion.
> >
> > I'm indexing a SQL database.  Each table is a Lucene index. 
>  Now, in 
> > table "A", I have a field called "Foo".  When I index it 
> into Lucene, 
> > I also end up with a field called "Foo".  Later on, the SQL 
> database 
> > administrator, will change the field name from "Foo" to 
> "Bar".  Once 
> > this happens, any new records added to table "A" will be 
> indexed into 
> > Lucene as "Bar".
> >
> > The issue is this, Lucene index for table "A" now has 
> documents with 
> > some having a field called "Foo" and others with "Bar".  This is 
> > problematic because now a user can't just search for "Foo:dog", but 
> > must search for "Foo:dog Bar:dog".
> >
> > So, what are my options here?  No, I can't re-index.  
> Ideally, I would 
> > like to be able to say to Lucene, "rename the field 'Foo' 
> to 'Bar' in 
> > the index
> > 'A'" (even if it means using private APIs).  Is this possible?   
> > Have you run
> > into this problem?  What was your solution?
> >
> > Regards,
> >
> > -- George
> >
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-user-help@lucene.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Can a Lucene field be renamed in a Lucene index?

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
there was just this thread here recently:

   <http://www.nabble.com/How-to-rename-fields-in-an-index- 
tf4310043.html#a12269902>

hope that helps.

	Erik


On Aug 29, 2007, at 10:03 PM, George Aroush wrote:

> Hi everyone,
>
> I have the following need and I wander what are my options or if  
> anyone run
> into it and has a solution / suggestion.
>
> I'm indexing a SQL database.  Each table is a Lucene index.  Now,  
> in table
> "A", I have a field called "Foo".  When I index it into Lucene, I  
> also end
> up with a field called "Foo".  Later on, the SQL database  
> administrator,
> will change the field name from "Foo" to "Bar".  Once this happens,  
> any new
> records added to table "A" will be indexed into Lucene as "Bar".
>
> The issue is this, Lucene index for table "A" now has documents  
> with some
> having a field called "Foo" and others with "Bar".  This is  
> problematic
> because now a user can't just search for "Foo:dog", but must search  
> for
> "Foo:dog Bar:dog".
>
> So, what are my options here?  No, I can't re-index.  Ideally, I  
> would like
> to be able to say to Lucene, "rename the field 'Foo' to 'Bar' in  
> the index
> 'A'" (even if it means using private APIs).  Is this possible?   
> Have you run
> into this problem?  What was your solution?
>
> Regards,
>
> -- George
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org