You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by "Nguyen, Joe" <jn...@automotive.com> on 2008/10/28 21:25:48 UTC

Changing field datatype

I have a solr core having 2 million lengthy documents.  

1.  If I modify datatype of a field 'foo' from string to a sint and
restart the server, what would happen to the existing documents? And
documents added with the new schema?  At query time (sort=foo desc),
should I expect the documents sorted properly? 

Do I need to re-index all documents?

2. If I add two additional fields, do I need to re-index again?

Thanks.

RE: Changing field datatype

Posted by "Nguyen, Joe" <jn...@automotive.com>.
Thanks for your quick reply.

What would be a reasonable way to handle this without affecting the end
users?  

Create a new dynamic core with the new schema, load documents to the new
core, then swap the cores?  At some moments, two mostly identical cores
co-exist on solr server, would that impact query time?   

-----Original Message-----
From: Shalin Shekhar Mangar [mailto:shalinmangar@gmail.com] 
Sent: Tuesday, October 28, 2008 1:33 Joe
To: solr-user@lucene.apache.org
Subject: Re: Changing field datatype

On Wed, Oct 29, 2008 at 1:55 AM, Nguyen, Joe <jn...@automotive.com>
wrote:

>
> 1.  If I modify datatype of a field 'foo' from string to a sint and
> restart the server, what would happen to the existing documents? And
> documents added with the new schema?  At query time (sort=foo desc),
> should I expect the documents sorted properly?

Do I need to re-index all documents?


The fields can't be converted automatically. Therefore, a sort on foo
will
still be a lexical sort instead of a numerical sort. You'll have to
re-index
to have "foo desc" give a numerically non-ascending sort order.


> 2. If I add two additional fields, do I need to re-index again?


The old documents won't have any values for those fields of course but
new
documents will. It is best to re-index to avoid any inconsistencies.

-- 
Regards,
Shalin Shekhar Mangar.

Re: Changing field datatype

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
On Wed, Oct 29, 2008 at 1:55 AM, Nguyen, Joe <jn...@automotive.com> wrote:

>
> 1.  If I modify datatype of a field 'foo' from string to a sint and
> restart the server, what would happen to the existing documents? And
> documents added with the new schema?  At query time (sort=foo desc),
> should I expect the documents sorted properly?

Do I need to re-index all documents?


The fields can't be converted automatically. Therefore, a sort on foo will
still be a lexical sort instead of a numerical sort. You'll have to re-index
to have "foo desc" give a numerically non-ascending sort order.


> 2. If I add two additional fields, do I need to re-index again?


The old documents won't have any values for those fields of course but new
documents will. It is best to re-index to avoid any inconsistencies.

-- 
Regards,
Shalin Shekhar Mangar.