# Convert SearchResponse to Pageable(Spring Data)

**URL:** <https://discuss.elastic.co/t/convert-searchresponse-to-pageable-spring-data/117611>\
**Category:** Elasticsearch\
**Created:** [January 30, 2018, 12:15pm UTC](https://discuss.elastic.co/t/convert-searchresponse-to-pageable-spring-data/117611 "2018-01-30T12:15:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nikita\_Krasnov](https://avatars.discourse-cdn.com/v4/letter/n/53a042/32.png) [@Nikita\_Krasnov](https://discuss.elastic.co/u/Nikita_Krasnov)\
**Post date:** [January 30, 2018, 12:15pm UTC](https://discuss.elastic.co/t/convert-searchresponse-to-pageable-spring-data/117611/1 "2018-01-30T12:15:32Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 27, 2018, 12:15pm UTC](https://discuss.elastic.co/t/convert-searchresponse-to-pageable-spring-data/117611/2 "2018-02-27T12:15:53Z")

</div>

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