I have a question about aliases and referenced col...
# community-help
g
I have a question about aliases and referenced collections (JOINs): What are you recommendations on this topic? Is it ok to reference an aliased collection or only a "real" collection must be referenced? In an ideal world I would deal in production with only aliases, meaning I could have a
taxonomy_production
alias with different versions
taxonomy_1
,
taxonomy_2
and at a time
taxonomy_production
might be an alias of
taxonomy_2
. But in both
taxonomy_1
and
taxonomy_2
I would have a field referencing `ext_coll_production`which is an alias of `ext_coll_1`(or
ext_coll_2
).
f
You can reference by alias as well, it will point to the collection that the alias points to
Correction: It will point to the first collection, not the aliased collections. So that's not completely the case. What you could do is always create a new copy of every collection that references the alias.
g
I'm not sure to fully understand what you mean by
It will point to the first collection, not the aliased collections
Which first collection? Let's say I have
coll_1
collection referencing
taxo_alias
. and
taxo_alias
is an alias for
taxo_1
. Currently when I query on
taxo_alias
or
taxo_1
joining on `coll_1`I have the impression to get
Copy code
"Failed to join on `coll_1`: No reference field found`
f
Sorry, by first I meant the collection the alias points to at the time of the referencing / child collection creation
g
so you mean the reference is static and not dynamic?
f
Exactly. If you have any specific use-case where it doesn't work, could you make a reproducible example through curl commands, so we can debug this further?
g
If it was fully dynamic I think it would be better but I can understand it may be complicated on you side to support it this way. Having this in mind I will rework my way of updating data. Currently I would say it's not a good idea to reference an alias because you don't know which collection is really referenced and having an explicit reference might be clearer. Let's say
taxo_alias
->
taxo_1
ext_coll_alias
->
ext_coll_1
references
taxo_1
taxo_alias
->
taxo_2
I need to duplicate
ext_coll_1
to
ext_coll_2
to explicitely reference
taxo_2
and then
ext_coll_alias
->
ext_coll_2
And in my RO queries I only reference aliases
f
JOINs are actively being worked on, currently we're focusing on adding support to query by and facet by joined fields. Dynamic references are a woozy because what if the aliased collection does not include the reference field that the other collections point to? There's a lot of stuff that need to be cared for in situations like the one described
👍 1
g
I'm still experimenting updates on collections with async reference and I have some weird behaviour: I deleted a collection
reaches
having an async ref on collection
taxo
and when I'm updating documents of
taxo
(with.
emplace
mode) I'm having 400s
Copy code
Collection `reaches` with async_reference to the collection `taxo` not found.
Which is expected because I deleted that
reaches
collection. And I have also 400s on the new collection
reaches_2
wit async ref
taxo
,
Copy code
Error while updating async reference field `segment_id` of collection `reaches_2`: Document `id: lr_1634368372_*` already has a reference to document `1783355` of `taxo` collection, having reference value `lr_1634368372
Does it mean I cannot update documents used in async ref ?
I feel like when deleting a collection with async ref to another collection, there is still reference to the deleted one. Is it expected? How to refresh the "state" to not have references to a deleted collection anymore?
f
Cc: @Harpreet Sangar
h
I deleted a collection
reaches
having an async ref on collection
taxo
and when I'm updating documents of
taxo
(with.
emplace
mode) I'm having 400s
Copy code
Collection `reaches` with async_reference to the collection `taxo` not found.
This must be a bug. When referencing collection is deleted, we must remove all the reference info from the referenced collection. I'll try to reproduce it locally.
👍 1
g
FYI I have really weird behavior like having 800 results in
facet_counts
but only 1 row in
hits
. Maybe it's related.
h
I was able to reproduce the issue https://github.com/typesense/typesense/pull/2229/files PR fixes it.
🙌 1
FYI I have really weird behavior like having 800 results in
facet_counts
but only 1 row in
hits
. Maybe it's related.
I don't think they are related. Can you share reproduction steps for this?