acreeger/elasticsearch-grails-demo

Problem rendering Json format from search query in restfullcontroller

Opened this issue · 0 comments

Hello,

I can't render results from search query in json format.
Here is my code:

class Post {

    Integer id
    String title
    String type
    String content

    static constraints = {
    }
    static searchable = true
}


class PostController extends RestfulController {

static responseFormats = ['json', 'xml']

    PostController() {
        super(Post)
    }

def search () {
Map searchResults = Post.search("test")
render searchResults
}

//Other methods..
}

It renders an Array.
If i write render searchResults as JSON, it returns this {"total":6,"searchResults":{"empty":false}}

Thanks in advance for your help !
R