Hi Phil,

I don't really have any query parsing/generation code to send you, because I'm 
not using Lucene directly. I'm using the Grails Searchable Plugin,
which builds on both Lucene and Compass. The only relevant information
I can give you is my Grails domain classes which show how I've mapped
my classes to the Lucene search index.

@Searchable
class Student {

    @SearchableProperty(accessor = 'property')
    String name
    
    static hasMany = [attendances: Attendance]

    @SearchableId(accessor = 'property')
    Long id

    @SearchableComponent
    Set<Attendance> getAttendances() {
        return attendances
    }
}

@Searchable(root = false)
class Attendance {

    static searchable = true
    static belongsTo = [student: Student, course: Course]

    @SearchableProperty(accessor = 'property')
    String mandatory = "Y"

    @SearchableId(accessor = 'property')
    Long id

    @SearchableComponent
    Course getCourse() {
        return course
    }
} 

@Searchable(root = false)
class Course {

    @SearchableProperty(accessor = 'property', name = "courseName")
    String name  

    @SearchableId(accessor = 'property')
    Long id
}

In order to execute a search I simply provide a Lucene query string such as 
"+courseName:cooking AND +mandatory:Y"

Cheers,
Don


      

Reply via email to