Skip to content

Commit 3afec61

Browse files
committed
fix
1 parent 617d8b2 commit 3afec61

File tree

1 file changed

+2
-65
lines changed

1 file changed

+2
-65
lines changed

openmetadata-service/src/main/java/org/openmetadata/service/resources/search/VectorSearchResource.java

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import io.swagger.v3.oas.annotations.responses.ApiResponse;
88
import io.swagger.v3.oas.annotations.tags.Tag;
99
import jakarta.ws.rs.Consumes;
10-
import jakarta.ws.rs.DefaultValue;
1110
import jakarta.ws.rs.GET;
1211
import jakarta.ws.rs.POST;
1312
import jakarta.ws.rs.Path;
@@ -18,7 +17,6 @@
1817
import jakarta.ws.rs.core.Response;
1918
import jakarta.ws.rs.core.SecurityContext;
2019
import java.util.Collections;
21-
import java.util.List;
2220
import java.util.Map;
2321
import java.util.UUID;
2422
import lombok.extern.slf4j.Slf4j;
@@ -42,73 +40,12 @@ public VectorSearchResource(Authorizer authorizer) {
4240
this.authorizer = authorizer;
4341
}
4442

45-
@GET
46-
@Path("/query")
47-
@Operation(
48-
operationId = "vectorSearch",
49-
summary = "Vector semantic search",
50-
description = "Search entities using vector embeddings for semantic similarity.",
51-
responses = {
52-
@ApiResponse(
53-
responseCode = "200",
54-
description = "Vector search results",
55-
content =
56-
@Content(
57-
mediaType = "application/json",
58-
schema = @Schema(implementation = VectorSearchResponse.class)))
59-
})
60-
public Response vectorSearch(
61-
@Context SecurityContext securityContext,
62-
@Parameter(description = "Search query text", required = true) @QueryParam("q") String query,
63-
@Parameter(description = "Entity type to filter results") @QueryParam("entityType")
64-
String entityType,
65-
@Parameter(description = "Number of results to return") @DefaultValue("10") @QueryParam("k")
66-
int k,
67-
@Parameter(description = "Score threshold for filtering")
68-
@DefaultValue("0.0")
69-
@QueryParam("threshold")
70-
double threshold) {
71-
if (!Entity.getSearchRepository().isVectorEmbeddingEnabled()) {
72-
return Response.status(Response.Status.SERVICE_UNAVAILABLE)
73-
.entity("{\"error\":\"Vector search is not enabled\"}")
74-
.build();
75-
}
76-
77-
if (query == null || query.isBlank()) {
78-
return Response.status(Response.Status.BAD_REQUEST)
79-
.entity("{\"error\":\"query parameter 'q' is required\"}")
80-
.build();
81-
}
82-
83-
OpenSearchVectorService vectorService = OpenSearchVectorService.getInstance();
84-
if (vectorService == null) {
85-
return Response.status(Response.Status.SERVICE_UNAVAILABLE)
86-
.entity("{\"error\":\"Vector search service is not initialized\"}")
87-
.build();
88-
}
89-
90-
try {
91-
Map<String, List<String>> filters =
92-
entityType != null && !entityType.isBlank()
93-
? Map.of("entityType", List.of(entityType))
94-
: Collections.emptyMap();
95-
96-
VectorSearchResponse response = vectorService.search(query, filters, k, k, threshold);
97-
return Response.ok(response).build();
98-
} catch (Exception e) {
99-
LOG.error("Vector search failed: {}", e.getMessage(), e);
100-
return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
101-
.entity("{\"error\":\"An internal error occurred\"}")
102-
.build();
103-
}
104-
}
105-
10643
@POST
10744
@Path("/query")
10845
@Consumes(MediaType.APPLICATION_JSON)
10946
@Operation(
110-
operationId = "vectorSearchPost",
111-
summary = "Vector semantic search (POST)",
47+
operationId = "vectorSearch",
48+
summary = "Vector semantic search",
11249
description = "Search entities using vector embeddings with full filter support.",
11350
responses = {
11451
@ApiResponse(

0 commit comments

Comments
 (0)