dev change to visual_matches engine
Test Workflow / test (push) Successful in 3s

This commit is contained in:
vladp
2026-02-11 18:12:44 +07:00
parent 6b73d01aeb
commit 6818b74307
2 changed files with 6 additions and 4 deletions
@@ -91,8 +91,10 @@ public class ImageFoundRequestHandler implements RequestHandler {
int page = imageSearchRequest.getPage() != null ? imageSearchRequest.getPage() : 1; int page = imageSearchRequest.getPage() != null ? imageSearchRequest.getPage() : 1;
YandexSearchResponse yandexSearchResponse = mapper.mapToYandexResponse(searchResponseYandex, page, 5); YandexSearchResponse yandexSearchResponse = mapper.mapToYandexResponse(searchResponseYandex, page, 5,
YandexSearchResponse googleSearchResponse = mapper.mapToYandexResponse(searchResponseGoogle, page, 5); "visual_matches");
YandexSearchResponse googleSearchResponse = mapper.mapToYandexResponse(searchResponseGoogle, page, 5,
"exact_matches");
List<YandexSearchResponse.ImageResult> results = new ArrayList<>(); List<YandexSearchResponse.ImageResult> results = new ArrayList<>();
results.addAll(googleSearchResponse.getImages()); results.addAll(googleSearchResponse.getImages());
@@ -11,10 +11,10 @@ import java.util.List;
public class SearchApiToYandexResponseMapper { public class SearchApiToYandexResponseMapper {
private final ObjectMapper objectMapper = new ObjectMapper(); private final ObjectMapper objectMapper = new ObjectMapper();
public YandexSearchResponse mapToYandexResponse(String searchApiJson, int page, int pageSize) throws IOException { public YandexSearchResponse mapToYandexResponse(String searchApiJson, int page, int pageSize, String findType) throws IOException {
JsonNode root = objectMapper.readTree(searchApiJson); JsonNode root = objectMapper.readTree(searchApiJson);
JsonNode visualMatches = root.path("visual_matches"); JsonNode visualMatches = root.path(findType);
YandexSearchResponse response = new YandexSearchResponse(); YandexSearchResponse response = new YandexSearchResponse();
List<YandexSearchResponse.ImageResult> images = new ArrayList<>(); List<YandexSearchResponse.ImageResult> images = new ArrayList<>();