RED-3239 Extended search result with dossierStatus, dossierTemplateId, assignee, fileAttributes and workflowStatus
This commit is contained in:
parent
480d488b2c
commit
70ba63771d
@ -23,6 +23,10 @@ public class MatchedDocument {
|
||||
private String dossierId;
|
||||
private String dossierTemplateId;
|
||||
private String fileId;
|
||||
private String dossierStatus;
|
||||
private String assignee;
|
||||
private Map<String, String> fileAttributes;
|
||||
private String workflowStatus;
|
||||
|
||||
@Builder.Default
|
||||
private Map<String, Set<String>> highlights = new HashMap<>();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.iqser.red.service.search.v1.server.service;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.DossierStatus;
|
||||
import com.iqser.red.service.search.v1.model.MatchedDocument;
|
||||
import com.iqser.red.service.search.v1.model.MatchedSection;
|
||||
@ -59,7 +60,7 @@ public class SearchService {
|
||||
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().query(convertQuery(query, dossierTemplateIds, dossierIds, fileId, assignee, getDossierStatusOrDefault(dossierStatus), workflowStatus, fileAttributes, returnSections))
|
||||
.from(getPageOrDefault(page) * getPageSizeOrDefault(pageSize))
|
||||
.size(getPageSizeOrDefault(pageSize))
|
||||
.fetchSource(new String[]{"dossierId", "fileId"}, new String[]{"sections"})
|
||||
.fetchSource(new String[]{"dossierId", "dossierTemplateId", "fileId", "assignee", "dossierStatus", "workflowStatus", "fileAttributes"}, new String[]{"sections"})
|
||||
.highlighter(new HighlightBuilder().field("sections.text").field("filename").field("fileAttributes.value").highlighterType("fvh"))
|
||||
.trackScores(true);
|
||||
|
||||
@ -226,6 +227,10 @@ public class SearchService {
|
||||
.dossierId((String) hit.getSourceAsMap().get("dossierId"))
|
||||
.dossierTemplateId((String) hit.getSourceAsMap().get("dossierTemplateId"))
|
||||
.fileId((String) hit.getSourceAsMap().get("fileId"))
|
||||
.dossierStatus((String) hit.getSourceAsMap().get("dossierStatus"))
|
||||
.assignee((String) hit.getSourceAsMap().get("assignee"))
|
||||
.fileAttributes(convertFileAttributes(hit.getSourceAsMap().get("fileAttributes")))
|
||||
.workflowStatus((String) hit.getSourceAsMap().get("workflowStatus"))
|
||||
.highlights(hit.getHighlightFields()
|
||||
.entrySet()
|
||||
.stream()
|
||||
@ -249,6 +254,18 @@ public class SearchService {
|
||||
}
|
||||
|
||||
|
||||
private Map<String, String> convertFileAttributes(Object fileAttributesSourceMap) {
|
||||
Map<String, String> fileAttributes = new HashMap<>();
|
||||
|
||||
if (fileAttributesSourceMap != null) {
|
||||
List<HashMap<String, String>> list = new ObjectMapper().convertValue(fileAttributesSourceMap, ArrayList.class);
|
||||
list.forEach(r -> fileAttributes.put(r.get("name"), r.get("value")));
|
||||
}
|
||||
|
||||
return fileAttributes;
|
||||
}
|
||||
|
||||
|
||||
private MatchedSection convertInnerHit(SearchHit hit) {
|
||||
|
||||
return MatchedSection.builder()
|
||||
|
||||
@ -73,6 +73,22 @@ public class SearchTest extends AbstractElasticsearchIntegrationTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
public void testSearchWithAllFilter() {
|
||||
// Arrange
|
||||
ClassPathResource textResource = new ClassPathResource("files/Text2.json");
|
||||
Text text = objectMapper.readValue(textResource.getInputStream(), Text.class);
|
||||
|
||||
documentIndexService.indexDocument("template1", "dossierId1", "fileId1", "S-Metolachlor_RAR_01_Volume_1_2018-09-06-1.pdf", text, "UserId", DossierStatus.ACTIVE, WorkflowStatus.NEW, Map.of("F1Key", "F1Value", "F2Key", "F2Value"));
|
||||
|
||||
// Act & Assert 1
|
||||
SearchResult result = searchService.search("S-Metolachlor", List.of("template1"), List.of("dossierId1"), "fileId1", "UserId", List.of(DossierStatus.ACTIVE.name(), DossierStatus.DELETED.name()), WorkflowStatus.NEW.name(), Map.of("F1Key", "F1Value"), 0, 10, false);
|
||||
assertThat(result.getMatchedDocuments().size()).isEqualTo(1);
|
||||
System.out.println(result);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Index two documents and filter
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user