Skip to content

Commit

Permalink
Replace spaces with conjunction in FTS query (#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
DementevNikita authored Jan 28, 2022
1 parent 114479f commit 735895c
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -140,7 +141,9 @@ public Insert<SearchEntrypointRecord> 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<Object> conditionField = field(
"? @@ to_tsquery(?)",
SEARCH_ENTRYPOINT.SEARCH_VECTOR,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 735895c

Please sign in to comment.