From a0bf3dfdb0d31c9d1677d327d01f13f99441b5ba Mon Sep 17 00:00:00 2001 From: Sam Leeflang Date: Wed, 5 Oct 2022 09:55:00 +0200 Subject: [PATCH] Elasticsearch fix --- .../dissco/backend/repository/ElasticSearchRepository.java | 6 +++--- .../java/eu/dissco/backend/service/AnnotationService.java | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/eu/dissco/backend/repository/ElasticSearchRepository.java b/src/main/java/eu/dissco/backend/repository/ElasticSearchRepository.java index 557e3e9b..b6a0b713 100644 --- a/src/main/java/eu/dissco/backend/repository/ElasticSearchRepository.java +++ b/src/main/java/eu/dissco/backend/repository/ElasticSearchRepository.java @@ -30,7 +30,7 @@ public List search(String query, int pageNumber, int pageSize) } var searchRequest = new SearchRequest.Builder() .index("new-dissco") - .q("_exists_:digitalSpecimen AND " + query) + .q("_exists_:digitalSpecimen.physicalSpecimenId AND " + query) .from(offset) .size(pageSize) .build(); @@ -42,7 +42,7 @@ public List search(String query, int pageNumber, int pageSize) public List getLatestSpecimen() throws IOException { var searchRequest = new SearchRequest.Builder() .index("new-dissco") - .q("_exists_:digitalSpecimen ") + .q("_exists_:digitalSpecimen.physicalSpecimenId ") .sort(s -> s.field(f -> f.field("created").order(SortOrder.Desc))) .size(10) .build(); @@ -54,7 +54,7 @@ public List getLatestSpecimen() throws IOException { public List getLatestAnnotation() throws IOException { var searchRequest = new SearchRequest.Builder() .index("new-dissco") - .q("_exists_:annotation ") + .q("_exists_:annotation.type ") .sort(s -> s.field(f -> f.field("created").order(SortOrder.Desc))) .size(10) .build(); diff --git a/src/main/java/eu/dissco/backend/service/AnnotationService.java b/src/main/java/eu/dissco/backend/service/AnnotationService.java index 184e1f7d..1141b4c8 100644 --- a/src/main/java/eu/dissco/backend/service/AnnotationService.java +++ b/src/main/java/eu/dissco/backend/service/AnnotationService.java @@ -1,6 +1,5 @@ package eu.dissco.backend.service; -import co.elastic.clients.elasticsearch.ElasticsearchClient; import com.fasterxml.jackson.databind.JsonNode; import eu.dissco.backend.client.AnnotationClient; import eu.dissco.backend.domain.AnnotationEvent;