client = MongoClient()
db = client['test']
connection = db['test']
conn.insert({"tags": ["first_1", "second_1"]})
conn.insert({"tags": ["first_2", "second_1"]})
conn.insert({"tags": ["first_3", "second_2"]})
print conn.distinct("tags")
I got as output:
[u'first_1', u'second_1', u'first_2', u'first_3', u'second_2']
How can I do this operation only with second elements of array? I need something like:
[u'second_1', u'second_2']