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 Zheng Lin Edwin Yeo <ed...@gmail.com> on 2015/06/05 05:53:15 UTC

Collection ID in Solr?

Hi,

Would like to check, does all the collections in Solr have an ID that is
stored internally which we can reference to?

Currently I believe we are using the name of the collection when we are
querying to the collection, and this can be modified as and when is
required. Whenever this is changed, it will cause problem with my program
as the old collection name doesn't exists anymore.

So would like to know, does Solr creates an unique ID when a collection is
created, and this ID shouldn't change even if the collection name is
changed?

I'm using Solr 5.1


Regards,
Edwin

Re: Collection ID in Solr?

Posted by Zheng Lin Edwin Yeo <ed...@gmail.com>.
Yup indeed there's a lot less JSON.

But are we able to configure this somewhere permanently?
Normally I don't query the ZooKeeper in my URL directly for my query.

Regards,
Edwin


On 5 June 2015 at 21:04, Shawn Heisey <ap...@elyograg.org> wrote:

> On 6/5/2015 1:46 AM, Zheng Lin Edwin Yeo wrote:
> > That's why we are trying to get the user to change something else instead
> > of the collection name. The collection alias sounds like a good option.
> >
> > Is there a way to list out all the alias names, or the only way is to
> > reference it at aliases.json file under the Cloud section in the Admin
> UI?
> >
> > As when I use the /admin/collections?action=LIST, it list the collection
> > names only, and I'm using this to populate the collections on the UI
> > dynamically. If the user is using the alias name, there's no need for
> them
> > to know the actual collection name. So I'm trying to find a way is there
> a
> > way to list out all the alias name.
>
> This is what the admin UI uses when it retrieves aliases.json to show it
> to you within the Cloud->Tree section:
>
> http://server:port/solr/zookeeper?detail=true&path=%2Faliases.json
>
> If you remove detail=true from that URL, there will be a lot less JSON
> to parse:
>
> http://server:port/solr/zookeeper?path=%2Faliases.json
>
> You'll need to figure out how to send that request with whatever Solr or
> HTTP client you are using, and then you will probably need to parse the
> JSON to get the information.
>
> If your client is SolrJ, it might offer an easier way to grab that
> information ... but I'm not familiar enough with the code to say for sure.
>
> Thanks,
> Shawn
>
>

Re: Collection ID in Solr?

Posted by Shawn Heisey <ap...@elyograg.org>.
On 6/5/2015 1:46 AM, Zheng Lin Edwin Yeo wrote:
> That's why we are trying to get the user to change something else instead
> of the collection name. The collection alias sounds like a good option.
> 
> Is there a way to list out all the alias names, or the only way is to
> reference it at aliases.json file under the Cloud section in the Admin UI?
> 
> As when I use the /admin/collections?action=LIST, it list the collection
> names only, and I'm using this to populate the collections on the UI
> dynamically. If the user is using the alias name, there's no need for them
> to know the actual collection name. So I'm trying to find a way is there a
> way to list out all the alias name.

This is what the admin UI uses when it retrieves aliases.json to show it
to you within the Cloud->Tree section:

http://server:port/solr/zookeeper?detail=true&path=%2Faliases.json

If you remove detail=true from that URL, there will be a lot less JSON
to parse:

http://server:port/solr/zookeeper?path=%2Faliases.json

You'll need to figure out how to send that request with whatever Solr or
HTTP client you are using, and then you will probably need to parse the
JSON to get the information.

If your client is SolrJ, it might offer an easier way to grab that
information ... but I'm not familiar enough with the code to say for sure.

Thanks,
Shawn


Re: Collection ID in Solr?

Posted by Zheng Lin Edwin Yeo <ed...@gmail.com>.
That's why we are trying to get the user to change something else instead
of the collection name. The collection alias sounds like a good option.

Is there a way to list out all the alias names, or the only way is to
reference it at aliases.json file under the Cloud section in the Admin UI?

As when I use the /admin/collections?action=LIST, it list the collection
names only, and I'm using this to populate the collections on the UI
dynamically. If the user is using the alias name, there's no need for them
to know the actual collection name. So I'm trying to find a way is there a
way to list out all the alias name.


Regards,
Edwin



On 5 June 2015 at 14:10, Shawn Heisey <ap...@elyograg.org> wrote:

> On 6/4/2015 11:39 PM, Zheng Lin Edwin Yeo wrote:
> > The reason is we want to allow flexibility to change the collection name
> > based on the needs of the users.
> >
> > For the collection aliasing, does this mean that the user will reference
> > the collection by the alias name instead of the collection name, but at
> the
> > backend we will still reference by the collection name? Whenever the user
> > wants to change the name, they'll just change the alias name, and leave
> the
> > collection name intact?
>
> The users can change the collection name? That sounds like a recipe for
> disaster.
>
> Collection aliases are a way for an admin to do index swapping in
> SolrCloud so that new indexes can be built and then swapped with the old
> index.  You build a collection named something like foo20150605 and then
> set up an alias named "foo" that points to that collection.  Your
> program doesn't need to know about the real collection name, the alias
> redirects all activity from the well-known name to the actual
> collection, and that mapping can change anytime it needs to.
>
> Thanks,
> Shawn
>
>

Re: Collection ID in Solr?

Posted by Shawn Heisey <ap...@elyograg.org>.
On 6/4/2015 11:39 PM, Zheng Lin Edwin Yeo wrote:
> The reason is we want to allow flexibility to change the collection name
> based on the needs of the users.
> 
> For the collection aliasing, does this mean that the user will reference
> the collection by the alias name instead of the collection name, but at the
> backend we will still reference by the collection name? Whenever the user
> wants to change the name, they'll just change the alias name, and leave the
> collection name intact?

The users can change the collection name? That sounds like a recipe for
disaster.

Collection aliases are a way for an admin to do index swapping in
SolrCloud so that new indexes can be built and then swapped with the old
index.  You build a collection named something like foo20150605 and then
set up an alias named "foo" that points to that collection.  Your
program doesn't need to know about the real collection name, the alias
redirects all activity from the well-known name to the actual
collection, and that mapping can change anytime it needs to.

Thanks,
Shawn


Re: Collection ID in Solr?

Posted by Zheng Lin Edwin Yeo <ed...@gmail.com>.
Hi Erick,

The reason is we want to allow flexibility to change the collection name
based on the needs of the users.

For the collection aliasing, does this mean that the user will reference
the collection by the alias name instead of the collection name, but at the
backend we will still reference by the collection name? Whenever the user
wants to change the name, they'll just change the alias name, and leave the
collection name intact?

Regards,
Edwin


On 5 June 2015 at 12:08, Erick Erickson <er...@gmail.com> wrote:

> In a word, no. Why do you change the collection name? If you're doing
> some sort of switching the collection, consider collection aliasing.
>
> Best,
> Erick
>
> On Thu, Jun 4, 2015 at 8:53 PM, Zheng Lin Edwin Yeo
> <ed...@gmail.com> wrote:
> > Hi,
> >
> > Would like to check, does all the collections in Solr have an ID that is
> > stored internally which we can reference to?
> >
> > Currently I believe we are using the name of the collection when we are
> > querying to the collection, and this can be modified as and when is
> > required. Whenever this is changed, it will cause problem with my program
> > as the old collection name doesn't exists anymore.
> >
> > So would like to know, does Solr creates an unique ID when a collection
> is
> > created, and this ID shouldn't change even if the collection name is
> > changed?
> >
> > I'm using Solr 5.1
> >
> >
> > Regards,
> > Edwin
>

Re: Collection ID in Solr?

Posted by Erick Erickson <er...@gmail.com>.
In a word, no. Why do you change the collection name? If you're doing
some sort of switching the collection, consider collection aliasing.

Best,
Erick

On Thu, Jun 4, 2015 at 8:53 PM, Zheng Lin Edwin Yeo
<ed...@gmail.com> wrote:
> Hi,
>
> Would like to check, does all the collections in Solr have an ID that is
> stored internally which we can reference to?
>
> Currently I believe we are using the name of the collection when we are
> querying to the collection, and this can be modified as and when is
> required. Whenever this is changed, it will cause problem with my program
> as the old collection name doesn't exists anymore.
>
> So would like to know, does Solr creates an unique ID when a collection is
> created, and this ID shouldn't change even if the collection name is
> changed?
>
> I'm using Solr 5.1
>
>
> Regards,
> Edwin