When you say 1 field, do you mean 1 field from each document in the bucket or do you mean a singular document?
If you mean the former, your current query appears to select 3 fields (two of which are meta fields) from each document in the customer bucket. The Couchbase Query Tutorial gives a good introduction to N1QL querying in Couchbase. Additionally, I’d recommend testing your query out in the Query Workbench to ensure it works as expected.
If you are trying to fetch a single document, this is best done with a KV lookup instead of a query, but requires that you have the key already.
Sorry that my question wasn’t explaining enough. I meant selecting only 1 field from each document. It works just fine when I run it as native query but I couldn’t manage to do so with Spring Data Couchbase.
I’ve been wondering if there is a suggested solution for selecting only one field from each document with Spring Data Couchbase.
Is there any reason you are using query instead of a simple DTO with a Interface called PhoneNumber that only has a getter for the phone number? This is covered in the Spring documentation:
@ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS)
@Query("SELECT iata, \"\" as __id, 0 as __cas from #{#n1ql.bucket} WHERE #{#n1ql.filter} order by meta().id")
List<String> getStrings();
@ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS)
@Query("SELECT length(iata), \"\" as __id, 0 as __cas from #{#n1ql.bucket} WHERE #{#n1ql.filter} order by meta().id")
List<Long> getLongs();