I have created the ts_vector columns in the relevant tables in my PostgreSQL database, and I now need to add the respective column types in the Exposed tables & entities so that I can perform FTS through my endpoint.
I have not managed to find any documentation on how to do this, here is what i’ve tried so far:
private const val TS_VECTOR_SQL_TYPE = "tsvector"
class TsVectorColumnType : ColumnType<String>() {
override fun sqlType(): String = TS_VECTOR_SQL_TYPE
override fun valueFromDB(value: Any): String? {
return value as String
}
override fun valueToDB(value: String?): Any? {
return PGobject().apply {
type = TS_VECTOR_SQL_TYPE
this.value = value
}.value
}
override fun notNullValueToDB(value: String): Any {
return PGobject().apply {
type = TS_VECTOR_SQL_TYPE
this.value = value
}
}
override fun nonNullValueToString(value: String): String {
return "'$value'"
}
}
Tried to create a custom column type for it and then use it like so in the table definitions val tsvectorContent = TsVectorColumnType()
.
Is this approach correct? If it is, I’m having trouble understanding how the logic would work for using it to search based on the user’s query.