You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clarify multi index semantics w.r.t. duplicates #580
@danielmewes: it seems confusing to me that geo multi-indexes remove duplicates when normal multi-indexes don't. Are we sure we want to do it that way?
Simple and compound indexes are unique: values (or combinations of values, for compound indexes) can only appear once, and a single document can have only one index. A multi index can index a single document multiple times with different values. For instance, a blog post might have multiple tags, and each tag might refer to multiple blog posts.
If simple and compound indexes are unique, does that mean that arbitrary expressions indexes are not?
What does it mean for a value to appear only once. Does that mean that if I have two documents with the same indexed value is a problem?
The following is confusing in two ways: "A single document can only have one index" 1) documents don't have indexes 2) does it mean that if a document belong to an simple index, it cannot belong at the same time to a compound index?
Also, the beginning of the page says:
RethinkDB supports different types of secondary indexes:
Simple indexes based on the value of a single field.
Compound indexes based on multiple fields.
Multi indexes based on arrays of values.
Indexes based on arbitrary expressions.
This is confusing, because "multi" in an attribute that can be applied to any of the 3 possible types of indexes (simple, compound, arbitrary). However, the list suggests that multi indexes are a different index type.
To me, the multi operator on an index is like having r.args() applied to the value to be indexed.
Also, why bother with the different index types, since the simple and compound indexes can be just special cases of the arbitrary expression type?
We're still working on the phrasing of that one paragraph, actually; my current take is
With simple and compound indexes, a single document can be indexed by only one index value (or one specific set of values, for compound indexes). A multi index can index a single document multiple times with different values. For instance, a blog post might have multiple tags, and each tag might refer to multiple blog posts.
Which might address some of your concerns. @danielmewes pointed out that it's probably best to avoid "unique" because they're not unique in the "unique constraints" sense; it doesn't say that documents have indexes; etc.
As for the way multi indexes are kind of "meta" and thus not like the others, while that might be a discussion worth having, we use the phrase multi index a lot throughout the documentation and to date, at least, I haven't gotten reports of users being too confused about this in practice -- the examples and more complete discussion past the introduction here (hopefully) make this fairly clear. Taking that bullet point out and finding a way to say "in addition, there's another thing we call an index which isn't technically an index but changes the way other indexes work, although in practice you'll use it just like an index" will be more accurate, but I think it'll be very hard to do that in a way which actually improves clarity -- the introduction block is supposed to be a pretty high-level overview. Maybe it's something we can make more explicit in the more detailed section on multi indexes here.
@mlucy Geo indexes generally have to filter duplicates, because even in a regular index a single document can appear in multiple places in the index tree.
I think we could theoretically make geo indexes emit duplicates in a multi index. This would work by comparing the tags that we generate for multi index index keys (specifically we could filter duplicates in the geo index based not just on their primary keys, but on the pair (primary key, multi index tag) ). It would require some additional code specifically for this in the geospatial index traversal code.
I don't think it's too confusing to have getIntersecting() and getNearest() never return duplicates, even if between() and getAll() do for multi indexes. But that's up for discussion. I opened rethinkdb/rethinkdb#3351 to discuss that aspect further.
Activity
nviennot commentedon Nov 17, 2014
also
get(1)should beget_all(1)right?danielmewes commentedon Nov 17, 2014
Oh yeah, it has to be
get_all(1)indeed or thefilterwon't work on it.mlucy commentedon Nov 18, 2014
@danielmewes: it seems confusing to me that geo multi-indexes remove duplicates when normal multi-indexes don't. Are we sure we want to do it that way?
nviennot commentedon Nov 18, 2014
I find the introduced doc fix confusing.
If simple and compound indexes are unique, does that mean that arbitrary expressions indexes are not?
What does it mean for a value to appear only once. Does that mean that if I have two documents with the same indexed value is a problem?
The following is confusing in two ways: "A single document can only have one index" 1) documents don't have indexes 2) does it mean that if a document belong to an simple index, it cannot belong at the same time to a compound index?
Also, the beginning of the page says:
This is confusing, because "multi" in an attribute that can be applied to any of the 3 possible types of indexes (simple, compound, arbitrary). However, the list suggests that multi indexes are a different index type.
To me, the multi operator on an index is like having
r.args()applied to the value to be indexed.Also, why bother with the different index types, since the simple and compound indexes can be just special cases of the arbitrary expression type?
chipotle commentedon Nov 18, 2014
We're still working on the phrasing of that one paragraph, actually; my current take is
Which might address some of your concerns. @danielmewes pointed out that it's probably best to avoid "unique" because they're not unique in the "unique constraints" sense; it doesn't say that documents have indexes; etc.
As for the way multi indexes are kind of "meta" and thus not like the others, while that might be a discussion worth having, we use the phrase multi index a lot throughout the documentation and to date, at least, I haven't gotten reports of users being too confused about this in practice -- the examples and more complete discussion past the introduction here (hopefully) make this fairly clear. Taking that bullet point out and finding a way to say "in addition, there's another thing we call an index which isn't technically an index but changes the way other indexes work, although in practice you'll use it just like an index" will be more accurate, but I think it'll be very hard to do that in a way which actually improves clarity -- the introduction block is supposed to be a pretty high-level overview. Maybe it's something we can make more explicit in the more detailed section on multi indexes here.
danielmewes commentedon Nov 18, 2014
@mlucy Geo indexes generally have to filter duplicates, because even in a regular index a single document can appear in multiple places in the index tree.
I think we could theoretically make geo indexes emit duplicates in a multi index. This would work by comparing the tags that we generate for multi index index keys (specifically we could filter duplicates in the geo index based not just on their primary keys, but on the pair (primary key, multi index tag) ). It would require some additional code specifically for this in the geospatial index traversal code.
I don't think it's too confusing to have
getIntersecting()andgetNearest()never return duplicates, even ifbetween()andgetAll()do for multi indexes. But that's up for discussion. I opened rethinkdb/rethinkdb#3351 to discuss that aspect further.Clarify wording; fixes #580