Query returning a primitive type are expected to return exactly 1 result, got 0

I want to check whether a value is present in json array or not.
For that i am returning Boolean value , following is my query

@Query(“Select discount_on_car from #{n1ql.bucket} where #{n1ql.filter} AND ANY carname IN discount_on_cars SATISFIES carname = $1 END AND discount_code = $2 AND discount_on_car = true LIMIT 1”)
Boolean findDiscountByCarANDByCode(String name, String discountcode);

Now if value is present then i get the result correct which is true.but if i insert some value which is not present in array it gives following error,

org.springframework.data.couchbase.core.CouchbaseQueryExecutionException: Query returning a primitive type are expected to return exactly 1 result, got 0

Instead it should give false.
Why is this error coming and how can i solve it?

The predicate of you query includes “and discount_on_car = true”. So when discount_on_car = false, the query returns nothing. Remove “and discount_on_car = true” and your query will return 1 result as long as the other predicates are satisfied.