Hello, In which cases an alias of a collection wil...
# community-help
g
Hello, In which cases an alias of a collection will be used ? It is something used only when we use search queries or it is also used for any other api?
k
All APIs will respect the alias. If it does not, then that will be a bug.
g
Ok thanks!
Is it intended that the aliased collection_name is something public?
k
The intent behind aliases is so that you can create a new collection behind the scenes and swap over to it without updating your code. For e.g. lets say you want to rebuild your search index daily. Your code can just refer to an alias, say
books
and then everyday you create a new collection, say
books_30_JUL_2021
, index it and then just update the
books
alias to point to this new collection.
If something goes wrong, easy to revert also.
g
Yep I see the alias behavior. But I thought the effective collection name wouldn't have been exposed to the search api. Let's say I have
product
alias to
product-Whatever
. And then I perform a search using only the search token. I wouldn't know about the existence of
product-whatever
k
The collections don't know about aliases. What benefit do you see in keeping the collection name private?
g
In my case I have a single cluster that contains indices for different environnements. My collection name is like so:
Copy code
`${name}-${environnement}-${date}`
With the alias I can then point wherever I want. My front application always ask for the alias. My backend layer create collection & appropriate alias dependending on the environnement. But the environnement is not something I would like to expose publicly. Nor the date. For now I can just compose the collection name without "readable information"
k
You can use different API key for each environment. The API keys allow you to define which collection can be accessed.
g
Yes, completely agree that should be the api key that controls the permission. I started on typesense cloud with one cluster per environnement. So I had different api keys. The issue was it cost me Runtime cpu on each cluster even if the environnement was not used at all. So I have put everything on the same cluster so if at least one env is used, the cluster is not running for nothing. 🙂 would have prefered to completely have separated envorinnements
k
I don't follow. How would having a single cluster prevent you from generating separate API keys for each collection?
g
ahhh my bad, didn't see there was an ability to give api key per collection. In fact I only had in mind the "generate api keys" from the administration interface. I'm on it reading this documentation section.
k
👍