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 Joseph Obernberger <jo...@gmail.com> on 2014/09/10 17:05:14 UTC

Modify Schema - Schema API

In addition to adding new fields to the schema, is there a way to modify an
existing field?  If I created a field called userID as a long, but decided
later that it should be a string?
Thank you!

-Joe

Re: Modify Schema - Schema API

Posted by Joseph Obernberger <jo...@gmail.com>.
Wow - that's really cool!  Thank you!

-Joe

On Wed, Sep 10, 2014 at 12:29 PM, Anshum Gupta <an...@anshumgupta.net>
wrote:

> You don't need to bring down the shards/collections, instead here's what
> you can do:
> * Retain the filename ("managed_schema", if you didn't change the default
> resource name).
> * Edit the file locally
> * Upload it to replace the current zk file.
> * Reload the collection(s).
> * Reindex
>
> Here's another thing you can do:
> * Upload the updated configs to zk
> * Create a new collection (different name) using the new configs
> * Reindex data to the new collection.
> * Use collection aliasing to swap the old/new collections.
> (http://www.anshumgupta.net/2013/10/collection-aliasing-in-solrcloud.html)
>
> All this while, you wouldn't really need to shut down the Solr
> cluster/collection etc.
>
> On Wed, Sep 10, 2014 at 8:56 AM, Joseph Obernberger <
> joseph.obernberger@gmail.com> wrote:
>
> > Thank you - yes that was my question.  I should have stated that it was
> for
> > SolrCloud and hence a managed schema.  Could I bring down the shards,
> edit
> > the managed schema on zookeeper, fire the shards back up and re-index?
> >
> > -Joe
> >
> > On Wed, Sep 10, 2014 at 11:50 AM, Anshum Gupta <an...@anshumgupta.net>
> > wrote:
> >
> > > Hi Joseph,
> > >
> > > It isn't supported by an exiting REST API (if that was your question)
> but
> > > you can always edit the schema manually (if it isn't managed), upload
> the
> > > new schema and reload the collections (or cores in case of
> non-SolrCloud
> > > mode).
> > >
> > > Do remember that changing the field type might require you to reindex
> > your
> > > data.
> > >
> > > There's an open JIRA for that one and I think someone would get to it
> > > sometime in the reasonably near future.
> > > JIRA: https://issues.apache.org/jira/browse/SOLR-5289
> > >
> > > On Wed, Sep 10, 2014 at 8:05 AM, Joseph Obernberger <
> > > joseph.obernberger@gmail.com> wrote:
> > >
> > > > In addition to adding new fields to the schema, is there a way to
> > modify
> > > an
> > > > existing field?  If I created a field called userID as a long, but
> > > decided
> > > > later that it should be a string?
> > > > Thank you!
> > > >
> > > > -Joe
> > > >
> > >
> > >
> > >
> > > --
> > >
> > > Anshum Gupta
> > > http://www.anshumgupta.net
> > >
> >
>
>
>
> --
>
> Anshum Gupta
> http://www.anshumgupta.net
>

Re: Modify Schema - Schema API

Posted by Anshum Gupta <an...@anshumgupta.net>.
You don't need to bring down the shards/collections, instead here's what
you can do:
* Retain the filename ("managed_schema", if you didn't change the default
resource name).
* Edit the file locally
* Upload it to replace the current zk file.
* Reload the collection(s).
* Reindex

Here's another thing you can do:
* Upload the updated configs to zk
* Create a new collection (different name) using the new configs
* Reindex data to the new collection.
* Use collection aliasing to swap the old/new collections.
(http://www.anshumgupta.net/2013/10/collection-aliasing-in-solrcloud.html)

All this while, you wouldn't really need to shut down the Solr
cluster/collection etc.

On Wed, Sep 10, 2014 at 8:56 AM, Joseph Obernberger <
joseph.obernberger@gmail.com> wrote:

> Thank you - yes that was my question.  I should have stated that it was for
> SolrCloud and hence a managed schema.  Could I bring down the shards, edit
> the managed schema on zookeeper, fire the shards back up and re-index?
>
> -Joe
>
> On Wed, Sep 10, 2014 at 11:50 AM, Anshum Gupta <an...@anshumgupta.net>
> wrote:
>
> > Hi Joseph,
> >
> > It isn't supported by an exiting REST API (if that was your question) but
> > you can always edit the schema manually (if it isn't managed), upload the
> > new schema and reload the collections (or cores in case of non-SolrCloud
> > mode).
> >
> > Do remember that changing the field type might require you to reindex
> your
> > data.
> >
> > There's an open JIRA for that one and I think someone would get to it
> > sometime in the reasonably near future.
> > JIRA: https://issues.apache.org/jira/browse/SOLR-5289
> >
> > On Wed, Sep 10, 2014 at 8:05 AM, Joseph Obernberger <
> > joseph.obernberger@gmail.com> wrote:
> >
> > > In addition to adding new fields to the schema, is there a way to
> modify
> > an
> > > existing field?  If I created a field called userID as a long, but
> > decided
> > > later that it should be a string?
> > > Thank you!
> > >
> > > -Joe
> > >
> >
> >
> >
> > --
> >
> > Anshum Gupta
> > http://www.anshumgupta.net
> >
>



-- 

Anshum Gupta
http://www.anshumgupta.net

Re: Modify Schema - Schema API

Posted by Joseph Obernberger <jo...@gmail.com>.
Thank you - yes that was my question.  I should have stated that it was for
SolrCloud and hence a managed schema.  Could I bring down the shards, edit
the managed schema on zookeeper, fire the shards back up and re-index?

-Joe

On Wed, Sep 10, 2014 at 11:50 AM, Anshum Gupta <an...@anshumgupta.net>
wrote:

> Hi Joseph,
>
> It isn't supported by an exiting REST API (if that was your question) but
> you can always edit the schema manually (if it isn't managed), upload the
> new schema and reload the collections (or cores in case of non-SolrCloud
> mode).
>
> Do remember that changing the field type might require you to reindex your
> data.
>
> There's an open JIRA for that one and I think someone would get to it
> sometime in the reasonably near future.
> JIRA: https://issues.apache.org/jira/browse/SOLR-5289
>
> On Wed, Sep 10, 2014 at 8:05 AM, Joseph Obernberger <
> joseph.obernberger@gmail.com> wrote:
>
> > In addition to adding new fields to the schema, is there a way to modify
> an
> > existing field?  If I created a field called userID as a long, but
> decided
> > later that it should be a string?
> > Thank you!
> >
> > -Joe
> >
>
>
>
> --
>
> Anshum Gupta
> http://www.anshumgupta.net
>

Re: Modify Schema - Schema API

Posted by Anshum Gupta <an...@anshumgupta.net>.
Hi Joseph,

It isn't supported by an exiting REST API (if that was your question) but
you can always edit the schema manually (if it isn't managed), upload the
new schema and reload the collections (or cores in case of non-SolrCloud
mode).

Do remember that changing the field type might require you to reindex your
data.

There's an open JIRA for that one and I think someone would get to it
sometime in the reasonably near future.
JIRA: https://issues.apache.org/jira/browse/SOLR-5289

On Wed, Sep 10, 2014 at 8:05 AM, Joseph Obernberger <
joseph.obernberger@gmail.com> wrote:

> In addition to adding new fields to the schema, is there a way to modify an
> existing field?  If I created a field called userID as a long, but decided
> later that it should be a string?
> Thank you!
>
> -Joe
>



-- 

Anshum Gupta
http://www.anshumgupta.net