I have the below kind of data stored in my collection called persons, I am using spring-data-couchbase
for reading this data in Java POJOs, and I am using the @Query
annotation in my PersonsRepository
class and writing SQL query for fetching data according to my need.
########## Document 1
{
"person": [
{
"id": "name",
"value": "abc"
},
{
"id": "age",
"value": 40
},
{
"id": "country",
"value": "usa"
}
],
"loggedOn": "2020-07-14"
}
########## Document 2
{
"person": [
{
"id": "name",
"value": "def"
},
{
"id": "age",
"value": 32
},
{
"id": "country",
"value": "uk"
}
],
"loggedOn": "2020-08-10"
}
Now I need to write SQL in Couchbase such that I can sort and paginate these documents by providing a value of person
's attribute.
I.e. sort by name or sort by age
Note: I do not want to download data in my Java POJO and then do sorting and paging, as it requires huge network bandwidth and I/O due to a large dataset.