grails / elasticsearch-grails-plugin

The Elasticsearch Grails plugin
https://grails-plugins.github.io/elasticsearch-grails-plugin/
Other
15 stars 23 forks source link

Failed to marshall domain instance Reference #178

Open nazarchaparov opened 2 years ago

nazarchaparov commented 2 years ago

Hello, I have 3 domain classes:

class Song extends AuditSection implements Serializable {

    static searchable = {
        artist reference: true
        songArtists component: true
    }

    Artist artist

    static hasMany = [songArtists: SongArtist]

}

class SongArtist implements Serializable {

    static searchable = {
        only = ["artist", "sortOrder"]
        root false
        artist reference: true
    }

    Artist artist
    Song song
    Integer sortOrder

}

class Artist extends AuditSection implements Serializable {

    static searchable = {
        except = ["songArtists", "songs"]
    }

    static hasMany = [songArtists: SongArtist, songs: Song]

}

When I index the main song class I get an error (i think, plugin incorrectly finds the ref class) : `2022-07-31 13:40:33.789 ERROR --- [nio-8282-exec-4] g.p.e.index.IndexRequestQueue : Error Indexing class com.tm.aydym.Song (index: com.tm.aydym.song_write , type: song) of id 9529

grails.plugins.elasticsearch.exception.IndexException: Failed to marshall domain instance [Ömrüme (ýyldyz artistler toplumy)] Caused by: java.lang.AssertionError: Marshalled object com.tm.aydym.artist.SongArtist : 730429 is not [class com.tm.aydym.artist.Artist].. Expression: refClass.isAssignableFrom(object.getClass()) at org.codehaus.groovy.runtime.InvokerHelper.assertFailed(InvokerHelper.java:422) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.assertFailed(ScriptBytecodeAdapter.java:663) at grails.plugins.elasticsearch.conversion.marshall.SearchableReferenceMarshaller.doMarshall(SearchableReferenceMarshaller.groovy:37) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498)`