From 1a04ed835c74a71e98719dfc5ae8e103e6c1411c Mon Sep 17 00:00:00 2001 From: kennethmhc Date: Tue, 23 Apr 2024 17:23:23 +0200 Subject: [PATCH] [APPEND][FSTORE-1135] Fix preview embedding in the UI when pk is not in the opensearch schema (#1765) (cherry picked from commit af7a7dec5a7c084f264c03364e70416b32c815e5) --- .../hops/hopsworks/vectordb/OpensearchVectorDatabase.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vector-db/src/main/java/io/hops/hopsworks/vectordb/OpensearchVectorDatabase.java b/vector-db/src/main/java/io/hops/hopsworks/vectordb/OpensearchVectorDatabase.java index 995e289797..65fed15e72 100644 --- a/vector-db/src/main/java/io/hops/hopsworks/vectordb/OpensearchVectorDatabase.java +++ b/vector-db/src/main/java/io/hops/hopsworks/vectordb/OpensearchVectorDatabase.java @@ -203,6 +203,12 @@ public void batchWrite(Index index, Map data) throws VectorDatab public List> preview(Index index, Set fields, int n) throws VectorDatabaseException { List> results = Lists.newArrayList(); + // If fields is empty, return no result, otherwise the search query matches any documents which may not + // belong to requested feature group. + if (fields.size() == 0) { + return results; + } + // Create a bool query BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();