From 735895cb0f97311c4fceaac597933eab111de5e0 Mon Sep 17 00:00:00 2001 From: DementevNikita <53081563+DementevNikita@users.noreply.github.com> Date: Fri, 28 Jan 2022 15:54:16 +0300 Subject: [PATCH] Replace spaces with conjunction in FTS query (#395) --- .../oddplatform/repository/util/JooqFTSHelper.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/util/JooqFTSHelper.java b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/util/JooqFTSHelper.java index 2ca93e30a..e54e78646 100644 --- a/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/util/JooqFTSHelper.java +++ b/odd-platform-api/src/main/java/org/opendatadiscovery/oddplatform/repository/util/JooqFTSHelper.java @@ -1,5 +1,6 @@ package org.opendatadiscovery.oddplatform.repository.util; +import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Objects; @@ -140,7 +141,9 @@ public Insert buildSearchEntrypointUpsert( .onConflict().doUpdate().set(JooqFTSHelper.onConflictSetMap(seTargetField)); } - public Condition ftsCondition(final String query) { + public Condition ftsCondition(final String plainQuery) { + final String query = String.join("&", plainQuery.split(" ")); + final Field conditionField = field( "? @@ to_tsquery(?)", SEARCH_ENTRYPOINT.SEARCH_VECTOR, @@ -213,9 +216,11 @@ public Condition compileFacetCondition(final FacetType facetType, return function.apply(filters); } - public Field ftsRankField(final Field vectorField, final String query) { + public Field ftsRankField(final Field vectorField, final String plainQuery) { requireNonNull(vectorField); + final String query = String.join("&", plainQuery.split(" ")); + return field( "ts_rank(?, to_tsquery(?))", vectorField,