How do I map the Grails Searchable plugin to more than two domain objects?

I use the Searchable plugin in my Grails application, but I am having trouble displaying it for more than two domain objects when returning valid search results. I have looked through the documentation of the Searchable plugin, but cannot find the answer to my question. Here is a very simple example of the domains that I have:

class Article {

     static hasMany = [tags: ArticleTag]

     String title
     String body
}

class ArticleTag {
     Article article
     Tag tag
}

class Tag {
     String name
}

Ultimately, what I want to do is find the articles by looking at their titles, tags, and related tags. Headings and tags will also be increased.

How can these classes be matched to achieve the desired results?

+3
source share
1 answer

, , , . , Article.

,

class Article {

    static searchable = { 
        // don't add id and version to index
        except = ['id', 'version']

        title boost: 2.0
        tag boost:2.0

        // make the name in the index be tag
        tagValues name: 'tag'
    }

     static hasMany = [tags: ArticleTag]


     String title
     String body

    // do not store tagValues in database
    static transients = ['tagValues']

    // create a string value holding all of the tags
    // this will store them with the Article object in the index
    String getTagValues() {
        tags.collect {it.tag}.join(", ")
    }
}
+3

Source: https://habr.com/ru/post/1769617/


All Articles