Convert SearchResponse to Pageable(Spring Data)


(Nikita Krasnov) #1

Hi to everybode.
How I can convert SearchResponse to Pageable(Spring Data)?
From such response:

{
    "code": 200,
    "error": "",
    "message": "",
    "data": {
        "hits": [
            {
                "score": "NaN",
                "id": "Zq8jRmEBnLx-Tpus1LRa",
                "type": "logs_info",
                "nestedIdentity": null,
                "version": -1,
                "fields": {},
                "highlightFields": {},
                "sortValues": [
                    1517236481000
                ],
                "matchedQueries": [],
                "explanation": null,
                "shard": null,
                "index": "portal-logs-30.01.2018",
                "clusterAlias": "",
                "sourceAsMap": {
                    "level": "ERROR",
                    "module": "test module",
                    "ip": "192.168.3.93",
                    "thread": "test thread",
                    "sessionId": "1",
                    "office": "of 52",
                    "message": "test message 34",
                    "userName": "user",
                    "timeStamp": "2018-01-29T14:34:41.000Z",
                    "userLogin": "user",
                    "node": "first node",
                    "system": "super system 0",
                    "port": 9400,
                    "header": "test Header 3",
                    "submodule": "test submodule",
                    "location": {
                        "lon": -71.34,
                        "lat": 41.12
                    },
                    "operation": "some operation",
                    "device": "some device"
                },
                "innerHits": null,
                "sourceAsString": "{\"timeStamp\":\"2018-01-29T14:34:41.000Z\",\"header\":\"test Header 3\",\"message\":\"test message 34\",\"level\":\"ERROR\",\"node\":\"first node\",\"system\":\"super system 0\",\"port\":9400,\"module\":\"test module\",\"submodule\":\"test submodule\",\"thread\":\"test thread\",\"operation\":\"some operation\",\"sessionId\":\"1\",\"userLogin\":\"user\",\"userName\":\"user\",\"office\":\"of 52\",\"location\":{\"lat\":41.12,\"lon\":-71.34},\"ip\":\"192.168.3.93\",\"device\":\"some device\"}",
                "sourceRef": {
                    "childResources": []
                },
                "fragment": false
            } 
],
        "totalHits": 1,
        "maxScore": "NaN",
        "fragment": true
    }
}

to that:

{
    "code": 200,
    "error": "",
    "message": "",
    "data": {
        "content": [
            "level": "ERROR",
                    "module": "test module",
                    "ip": "192.168.3.93",
                    "thread": "test thread",
                    "sessionId": "1",
                    "office": "of 52",
                    "message": "test message 34",
                    "userName": "user",
                    "timeStamp": "2018-01-29T14:34:41.000Z",
                    "userLogin": "user",
                    "node": "first node",
                    "system": "super system 0",
                    "port": 9400,
                    "header": "test Header 3",
                    "submodule": "test submodule",
                    "location": {
                        "lon": -71.34,
                        "lat": 41.12
                    },
                    "operation": "some operation",
                    "device": "some device"
],
        "last": true,
        "totalPages": 1,
        "totalElements": 1,
        "size": 20,
        "number": 0,
        "sort": null,
        "first": true,
        "numberOfElements": 1
    }
}

Can somebody give me the example of java code?


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.