I have following query,
SELECT pin
.pin_id
,pin
.images
,pin
.identifier
FROM activity
USE INDEX(activity_pin_identifier
USING GSI) UNNEST pins
AS pin
WHERE META(activity
).id=‘d2f058d3a8d0daa6535bcbf3abfc4819’ AND pin
.identifier=‘83017b49ea3a4d8a9501c828de21286a’;
This gives no result when I index identifier key but when I remove indexing from identifier key, this query gives result but that is slow and takes somewhere around 400ms.I am using identifier to check duplicacy
Demo document I have in my database
[
{
"pin": {
"action": {
"commentCount": 0,
"flagCount": 0,
"likeCount": 0
},
"alt": 11.1,
"cat_id": "2",
"cat_name": "Traffic Issues",
"child_cat_id": "15",
"child_cat_name": "Accident",
"course": 11.11,
"expiry_date": 1829727003,
"flag": 1,
"identifier": "83017b49ea3a4d8a9501c828de21286a",
"images": [],
"modified_by": "",
"name": "NAVIMAPS",
"photo": "avatar.jpg",
"pin_create_date": "2017-12-25 15:00:04",
"pin_id": "35427",
"pin_privacy": 0,
"pin_rate": 0,
"pin_story": "accident",
"pin_story_title": "",
"pin_type": "report",
"place_id": "",
"place_lat": 28.478456,
"place_long": 77.15326,
"place_name": "",
"point": 0,
"progress": 0,
"quality": 30,
"social_id": 101,
"speed": 44.2,
"status": 1,
"user_id": "d2f058d3a8d0daa6535bcbf3abfc4819",
"user_name": "NAVIMAPS",
"utc": 1465195349
}
}
]
This is the query I ran to index identifier key
CREATE INDEX activity_pin_identifier
ON activity
((distinct (array (pin
.identifier
) for pin
in pins
end)))