[
https://issues.apache.org/jira/browse/COUCHDB-2867?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15962092#comment-15962092
]
Jan Lehnardt commented on COUCHDB-2867:
---------------------------------------
[~buhrmi] Thanks, I agree that. [] could be optional, the indexer knows when
`tags` is an array, so it can imply the .[] for both scalar and object arrays:
{code:json}
{"tags": ["green", "red", "blue"]}
{code}
{code:json}
{
"fields": "tags"
}
{code}
{code:json}
{"tags": [{"name":"green"}, {"name":"red"}, {"name":"blue"}]}
{code}
{code:json}
{
"fields": "tags.name"
}
{code}
The only downside is that it is not clear from the index definition that an
array is to be indexed, which might be surprising, especially when the person
that writes index and the person that operates the CouchDB instance are
separate people.
I’d be in favour of making it explicit, plus it is close enough to MongoDB to
be not too confusing, but I’d need to hear from people with more experience in
using all this.
> Mango: should be able to index *within* arrays
> ----------------------------------------------
>
> Key: COUCHDB-2867
> URL: https://issues.apache.org/jira/browse/COUCHDB-2867
> Project: CouchDB
> Issue Type: Improvement
> Components: Mango
> Reporter: Nolan Lawson
>
> If you have a document like:
> {code:javascript}
> {
> "_id": "foo",
> "tags": ["a", "b", "c"]
> }
> {code}
> ...then you should be able to run queries that find e.g. all documents with
> "a" as a tag, and it should be *indexed*. Currently there doesn't seem to be
> any way to do this except as an in-memory selector, which is a real bummer,
> because it's a super common use case. (Tags, categories, labels, etc.)
> Originally I thought this was how {{$elemMatch}} worked, and I was surprised
> to learn that that's not the case.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)