2

I am using searchable plugin in my project. And i have a simple domain, which given below

    Class User {
        String title
        String Description
        int vote
        Date date
            }
    static searchable = {
            only: ['description','title','vote','date']
            date name: 'sortableTitle1', index: 'not_analyzed'
            vote name: 'sortableTitle2', index: 'not_analyzed'

}

My need is to make vote and date as a sortable element. and it should not regarded while searching
Also i know, it can done by using below code

date name: 'sortableTitle1', index: 'not_analyzed' store:'no'

But in this case the result list of object will not contain date property, so it can't be displayed in gsp for display.
So how i can make 'date' element for displaying, sorting and not for searching in my gsp.

An Ish A
  • 711
  • 5
  • 18
  • May be not the best thing to do, but this what I did for the the same kind of problem: I set a mapping for my class, and Searchable helped me to get Ids. With ids, I use getAll method get all objects (automatically sort with the mapping). – Abincepto Apr 25 '14 at 16:00
  • 1
    @ArrrghGrails how you set mapping for class – An Ish A Apr 26 '14 at 04:40

1 Answers1

1

I can't add new comment, so here is the next part of my answer:

how you set mapping for class:

You can declare the default sort order for a collection in the mapping (documentation).

I hope it is what you need !

Example found in the documentation:

To "replace", for example, this:

def airports = Airport.list(sort:'name')

You can use

class Airport {
    …
    static mapping = {
        sort name: "desc"
    }
}

And the the first part of my answer:

May be not the best thing to do, but this what I did for the the same kind of problem: I set a mapping for my class, and Searchable helped me to get Ids. With ids, I use getAll method get all objects (automatically sort with the mapping).

Abincepto
  • 1,016
  • 8
  • 13