You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lucenenet.apache.org by George Aroush <ge...@aroush.net> on 2007/08/30 04:02:43 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


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

Posted by Michael Mitiaguin <mi...@gmail.com>.
George,
I am not sure how your search works , but why not to introduce some mapping
table field name - lucene field name and always keep lucene field the same
regardless of changes in table column names. The same mapping may be used
when searching

Regards
Michael

On 8/30/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
>
>

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

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
DIGY - that won't work if the fields are not stored, though.

	Erik


On Aug 30, 2007, at 4:12 AM, DIGY wrote:

> Hi George,
>
> What I was trying to say was simply:
>
> 		IndexSearcher sr = new IndexSearcher(@"c:\temp\blabla");
>             for (int i = 0; i < sr.Reader.NumDocs(); i++)
>             {
>
>                 Document d = sr.Reader.Document(i);
> 		    //Create NewDoc	
>                 //Write NewDoc to Second Index
>             }
>
> DIGY
>
>
>
> -----Original Message-----
> From: George Aroush [mailto:george@aroush.net]
> Sent: Thursday, August 30, 2007 5:30 AM
> To: lucene-net-user@incubator.apache.org
> Subject: RE: Can a Lucene field be renamed in a Lucene index?
>
> Hi DIGY,
>
> I don't understand.  How can one read documents from the source  
> index?  Yes,
> this would be possible if my source index also contains the raw- 
> text (for
> each field).
>
> Regards,
>
> -- George 
>
>> -----Original Message-----
>> From: DIGY [mailto:digydigy@gmail.com]
>> Sent: Wednesday, August 29, 2007 10:14 PM
>> To: lucene-net-user@incubator.apache.org
>> Subject: RE: Can a Lucene field be renamed in a Lucene index?
>>
>> Hi George,
>>
>> I haven't seen any API to do that thing, but one possibility can be:
>> Reading the all docs from source index
>> And writing the new values to the second one (Of course this
>> is re-index but does not require the original documents)
>>
>> DIGY
>>
>> -----Original Message-----
>> From: George Aroush [mailto:george@aroush.net]
>> Sent: Thursday, August 30, 2007 5:03 AM
>> To: lucene-net-user@incubator.apache.org
>> Subject: 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
>>


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

Posted by DIGY <di...@gmail.com>.
Hi George,

What I was trying to say was simply:

		IndexSearcher sr = new IndexSearcher(@"c:\temp\blabla");
            for (int i = 0; i < sr.Reader.NumDocs(); i++)
            {
             
                Document d = sr.Reader.Document(i);
		    //Create NewDoc	
                //Write NewDoc to Second Index
            }

DIGY



-----Original Message-----
From: George Aroush [mailto:george@aroush.net] 
Sent: Thursday, August 30, 2007 5:30 AM
To: lucene-net-user@incubator.apache.org
Subject: RE: Can a Lucene field be renamed in a Lucene index?

Hi DIGY,

I don't understand.  How can one read documents from the source index?  Yes,
this would be possible if my source index also contains the raw-text (for
each field).

Regards,

-- George 

> -----Original Message-----
> From: DIGY [mailto:digydigy@gmail.com] 
> Sent: Wednesday, August 29, 2007 10:14 PM
> To: lucene-net-user@incubator.apache.org
> Subject: RE: Can a Lucene field be renamed in a Lucene index?
> 
> Hi George,
> 
> I haven't seen any API to do that thing, but one possibility can be:
> Reading the all docs from source index
> And writing the new values to the second one (Of course this 
> is re-index but does not require the original documents)
> 
> DIGY
> 
> -----Original Message-----
> From: George Aroush [mailto:george@aroush.net]
> Sent: Thursday, August 30, 2007 5:03 AM
> To: lucene-net-user@incubator.apache.org
> Subject: 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
> 


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

Posted by George Aroush <ge...@aroush.net>.
Hi DIGY,

I don't understand.  How can one read documents from the source index?  Yes,
this would be possible if my source index also contains the raw-text (for
each field).

Regards,

-- George 

> -----Original Message-----
> From: DIGY [mailto:digydigy@gmail.com] 
> Sent: Wednesday, August 29, 2007 10:14 PM
> To: lucene-net-user@incubator.apache.org
> Subject: RE: Can a Lucene field be renamed in a Lucene index?
> 
> Hi George,
> 
> I haven't seen any API to do that thing, but one possibility can be:
> Reading the all docs from source index
> And writing the new values to the second one (Of course this 
> is re-index but does not require the original documents)
> 
> DIGY
> 
> -----Original Message-----
> From: George Aroush [mailto:george@aroush.net]
> Sent: Thursday, August 30, 2007 5:03 AM
> To: lucene-net-user@incubator.apache.org
> Subject: 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
> 


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

Posted by DIGY <di...@gmail.com>.
Hi George,

I haven't seen any API to do that thing, but one possibility can be:
Reading the all docs from source index
And writing the new values to the second one
(Of course this is re-index but does not require the original documents)

DIGY

-----Original Message-----
From: George Aroush [mailto:george@aroush.net] 
Sent: Thursday, August 30, 2007 5:03 AM
To: lucene-net-user@incubator.apache.org
Subject: 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