How to format string and perform select operation on formated string in single N1Ql query

I want to store multiple image name with number sequence at the end ,
but before that i want to check whether the image exist or not and if exist then get the last image name
eg: image-1,
image-2,
image-3

like above example name of image with number sequence.
I am using n1ql query in my java project as shown below example,

@Query("#{#n1ql.selectEntity} where #{#n1ql.filter} and username = $1 LIMIT 1")

Now couchbase gives some functionality like Contains to find a string contains in a given value.
But how can i perform a query to check whether the image name exist or not and if exist then get the last image name in a single query?

post the sample document

Please go through this link you can find every details

Checkout How to create Index of json array with only values?