I have exactly the same problem as stated here: <h...
# spring
b
I have exactly the same problem as stated here: https://stackoverflow.com/questions/51152549/solr-fields-being-mapped-to-array-when-using-kotlin-and-spring-data-solr . Any idea on how to resolve that?
Copy code
@SolrDocument(solrCoreName ="indexedcitation")
data class IndexedCitation (
    @Id
    @Indexed(name = "id", type = "string")
    private val id: String? = null,

    @Indexed(name = "title", type = "string")
    private val title: String? = null
)
that's my data class
This works:
Copy code
@SolrDocument(solrCoreName ="indexedcitation")
class IndexedCitation {
    @Id
    @Indexed(name = "id", type = "string")
    private var id: String? = null

    @Indexed(name = "title", type = "string")
    private var title: String? = null


    fun getId(): String? {
        return id
    }

    fun setId(id: String?) {
        this.id = id
    }

    fun getTitle(): String? {
        return title
    }

    fun setTitle(title: String?) {
        this.title = title
    }
}
if I add a constructor to that class, it fails
t
with data classes, annotations are added to the constructor parameter (I think). I don't know how
spring-data-solr
works, but you can try to annotate with
@field:Id @field:Indexed
etc etc to force the annotation to be placed on the field
b
I tried that to no avail… Now that I installed the spring-boot module for kotlin I don't see the problem anymore