diff --git a/vitrivr-engine-module-pgvector/src/main/kotlin/org/vitrivr/engine/database/pgvector/descriptor/scalar/ScalarDescriptorReader.kt b/vitrivr-engine-module-pgvector/src/main/kotlin/org/vitrivr/engine/database/pgvector/descriptor/scalar/ScalarDescriptorReader.kt index 362b7eea3..a077e61b5 100644 --- a/vitrivr-engine-module-pgvector/src/main/kotlin/org/vitrivr/engine/database/pgvector/descriptor/scalar/ScalarDescriptorReader.kt +++ b/vitrivr-engine-module-pgvector/src/main/kotlin/org/vitrivr/engine/database/pgvector/descriptor/scalar/ScalarDescriptorReader.kt @@ -64,10 +64,11 @@ class ScalarDescriptorReader(field: Schema.Field<*, ScalarDescriptor<*, *>>, con * @return [Sequence] of [ScalarDescriptor]s. */ private fun queryFulltext(query: SimpleFulltextQuery): Sequence> { - val statement = "SELECT * FROM \"$tableName\" WHERE $VALUE_ATTRIBUTE_NAME @@ plainto_tsquery(?)" + val queryString = query.value.value.split(" ").map { "$it:*" }.joinToString(" | ") { it } + val statement = "SELECT * FROM \"${tableName.lowercase()}\" WHERE ${query.attributeName} @@ to_tsquery(?)" return sequence { this@ScalarDescriptorReader.connection.jdbc.prepareStatement(statement).use { stmt -> - stmt.setString(1, query.value.value) + stmt.setString(1, queryString) stmt.executeQuery().use { result -> while (result.next()) { yield(rowToDescriptor(result)) diff --git a/vitrivr-engine-module-pgvector/src/main/kotlin/org/vitrivr/engine/database/pgvector/descriptor/struct/StructDescriptorReader.kt b/vitrivr-engine-module-pgvector/src/main/kotlin/org/vitrivr/engine/database/pgvector/descriptor/struct/StructDescriptorReader.kt index ef87ccb7d..c319eadc9 100644 --- a/vitrivr-engine-module-pgvector/src/main/kotlin/org/vitrivr/engine/database/pgvector/descriptor/struct/StructDescriptorReader.kt +++ b/vitrivr-engine-module-pgvector/src/main/kotlin/org/vitrivr/engine/database/pgvector/descriptor/struct/StructDescriptorReader.kt @@ -86,10 +86,11 @@ class StructDescriptorReader(field: Schema.Field<*, StructDescriptor<*>>, connec */ private fun queryFulltext(query: SimpleFulltextQuery): Sequence> { require(query.attributeName != null) { "Query attribute must not be null for a fulltext query on a struct descriptor." } - val statement = "SELECT * FROM \"${tableName.lowercase()}\" WHERE ${query.attributeName} @@ plainto_tsquery(?)" + val queryString = query.value.value.split(" ").map { "$it:*" }.joinToString(" | ") { it } + val statement = "SELECT * FROM \"${tableName.lowercase()}\" WHERE ${query.attributeName} @@ to_tsquery(?)" return sequence { this@StructDescriptorReader.connection.jdbc.prepareStatement(statement).use { stmt -> - stmt.setString(1, query.value.value) + stmt.setString(1, queryString) stmt.executeQuery().use { result -> while (result.next()) { yield(rowToDescriptor(result))