I have a field called storeImageNameList which stores image names,
Now if i want to get value by image name then how to create index on json array,
Eg: storeImageNameList :[“image1”,“image2”,“image3”…]
CREATE INDEX ix1 ON default(DISTINCT ARRAY c FOR c IN usedcarimages END)
WHERE _class = "com.usedCars.ServiceUsedCars.pojo.UsedCarDetails";
SELECT d.*
FROM default AS d
WHERE d._class = "com.usedCars.ServiceUsedCars.pojo.UsedCarDetails"
AND ANY c IN d.usedcarimages SATISFIES c = "Bridge001" END;
Last Image name in the array
SELECT d.usedcarimages[-1] AS lastimage
FROM default AS d
WHERE d._class = "com.usedCars.ServiceUsedCars.pojo.UsedCarDetails"
AND ANY c IN d.usedcarimages SATISFIES c = "Bridge001" END;
If you want sort and get last image
SELECT ARRAY_SORT(d.usedcarimages)[-1] AS lastimage
FROM default AS d
WHERE d._class = "com.usedCars.ServiceUsedCars.pojo.UsedCarDetails"
AND ANY c IN d.usedcarimages SATISFIES c = "Bridge001" END;