Skip to content

Commit

Permalink
Fulltext fixes for EA 3891
Browse files Browse the repository at this point in the history
  • Loading branch information
nshweta90 committed Aug 1, 2024
1 parent 4bc5e40 commit 08c2aa0
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package eu.europeana.fulltext.search.model.response;

import com.fasterxml.jackson.annotation.JsonProperty;
import eu.europeana.fulltext.entity.AnnoPage;
import eu.europeana.fulltext.entity.Annotation;

Expand All @@ -12,6 +13,10 @@
* Created on 2 June 2020
*/
public interface SearchResult {

@JsonProperty("@context")
// note that we only set context for a single annotation and not for an array of annotations part of an annotationpage
String[] getContext();
String getId();

String getType();
Expand All @@ -23,5 +28,7 @@ public interface SearchResult {
void addAnnotationHit(AnnoPage annoPage, Annotation annotation, Hit hit);

List<Hit> getHits();

void setContext(String[] context);
}

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.ArrayList;
import java.util.List;

@JsonPropertyOrder({"id", "type", "debug", "resources", "hits"})
@JsonPropertyOrder({"context","id", "type", "debug", "resources", "hits"})
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SearchResultV2 implements Serializable, SearchResult {

Expand All @@ -36,6 +36,11 @@ public SearchResultV2(String searchId, boolean debug) {
}
}

@Override
public String[] getContext() {
return new String[0];
}

@Override
@JsonProperty("@id")
public String getId() {
Expand Down Expand Up @@ -77,4 +82,9 @@ public void addAnnotationHit(AnnoPage annoPage, Annotation annotation, Hit hit)
public List<Hit> getHits() {
return hits;
}

@Override
public void setContext(String[] context) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.ArrayList;
import java.util.List;

@JsonPropertyOrder({"id", "type", "debug", "items", "hits"})
@JsonPropertyOrder({"context","id", "type", "debug", "items", "hits"})
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SearchResultV3 implements Serializable, SearchResult {

Expand All @@ -34,6 +34,11 @@ public SearchResultV3(String searchId, boolean debug) {
}
}

@Override
public String[] getContext() {
return new String[0];
}

public String getId() {
return id;
}
Expand Down Expand Up @@ -65,6 +70,11 @@ public List<Hit> getHits() {
return hits;
}

@Override
public void setContext(String[] context) {

}

/**
* Add an Annotation and optionally a Hit to the search result
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package eu.europeana.fulltext.search.service;

import static eu.europeana.iiif.IIIFDefinitions.MEDIA_TYPE_EDM_JSONLD;
import static eu.europeana.iiif.IIIFDefinitions.MEDIA_TYPE_IIIF_V2;
import static eu.europeana.iiif.IIIFDefinitions.TEXT_GRANULARITY_CONTEXT;

import dev.morphia.query.internal.MorphiaCursor;
import eu.europeana.api.commons.error.EuropeanaApiException;
import eu.europeana.fulltext.AnnotationType;
Expand Down Expand Up @@ -89,6 +93,7 @@ public SearchResult searchIssue(String searchId, EuropeanaId europeanaId, String
findAnnopageAndAnnotations(result, solrResult, europeanaId, pageSize, annoTypes, requestVersion);
}
LOG.debug("Search done in {} ms. Found {} annotations", (System.currentTimeMillis() - start), result.itemSize());
result.setContext(new String[]{MEDIA_TYPE_IIIF_V2, TEXT_GRANULARITY_CONTEXT,MEDIA_TYPE_EDM_JSONLD});
return result;
}

Expand Down

0 comments on commit 08c2aa0

Please sign in to comment.