Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
import fr.gouv.vitamui.commons.vitam.api.dto.VitamUISearchResponseDto;
import fr.gouv.vitamui.commons.vitam.api.model.UnitTypeEnum;
import fr.gouv.vitamui.iam.security.service.SecurityService;
import jakarta.validation.constraints.NotNull;
import jakarta.ws.rs.core.Response;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -111,6 +112,10 @@
@Service
public class ArchiveSearchService {

@Value("${tree-nodes-search-facets-size:1000}")
@NotNull
private Integer treeNodesSearchFacetsSize;

private static final Logger LOGGER = LoggerFactory.getLogger(ArchiveSearchService.class);
private static final String ARCHIVE_UNIT_DETAILS = "$results";
private static final String HISTORY = "$history";
Expand Down Expand Up @@ -188,7 +193,7 @@ public VitamUIArchiveUnitResponseDto searchArchiveUnitsByCriteria(final SearchCr
archiveSearchAgenciesService.mapAgenciesNameToCodes(searchQuery, vitamContext);
archiveSearchRulesService.mapManagementRulesTitlesToCodes(searchQuery, vitamContext);

JsonNode dslQuery = createDslQueryWithFacets(searchQuery).getFinalSelect();
JsonNode dslQuery = createDslQueryWithFacets(searchQuery, treeNodesSearchFacetsSize).getFinalSelect();
JsonNode vitamResponse = searchArchiveUnits(dslQuery, vitamContext);
ArchiveUnitsDto archiveUnitsDto = decorateAndMapResponse(vitamResponse, vitamContext);
Integer totalResults = archiveUnitsDto.getArchives().getHits().getTotal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,4 @@ logging:

# external ontology file path
ontologies_file_path: "src/main/resources/ontology/external_ontology_fields.json"
tree-nodes-search-facets-size: 1000
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ public class TransactionArchiveUnitService {
@Value("${ontologies_file_path}")
private String ontologiesFilePath;

@Value("${tree-nodes-search-facets-size:1000}")
@NotNull
private Integer treeNodesSearchFacetsSiz;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo, il manque le e à Size


public VitamUIArchiveUnitResponseDto searchArchiveUnitsByCriteria(
String transactionId,
SearchCriteriaDto searchQuery,
Expand All @@ -189,7 +193,7 @@ public VitamUIArchiveUnitResponseDto searchArchiveUnitsByCriteria(
SanityChecker.sanitizeCriteria(searchQuery);
SelectMultiQuery searchQuerySelectMultiQuery = isEmpty(searchQuery.getCriteriaList())
? getBasicQuery(searchQuery)
: createDslQueryWithFacets(searchQuery);
: createDslQueryWithFacets(searchQuery, treeNodesSearchFacetsSiz);
/* Perform query */
JsonNode searchQueryToDSL = searchQuerySelectMultiQuery.getFinalSelect();
final RequestResponse<JsonNode> result = collectService.searchUnitsByTransactionId(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,4 @@ logging:

# ontology fields file path
ontologies_file_path: "src/main/resources/ontology/external_ontology_fields.json"
tree-nodes-search-facets-size: 1000
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ public enum CriteriaOperators {
public static final String ORIGINATING_AGENCY_ID_FIELD = "SP_CODE";

public static final int DEFAULT_DEPTH = 10;
public static final int FACET_SIZE_MULTIPLIER = 100;

/* Query fields */
public static final String IDENTIFIER = "Identifier";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
import static fr.gouv.vitamui.commons.api.utils.ArchiveSearchConsts.DEFAULT_DEPTH;
import static fr.gouv.vitamui.commons.api.utils.ArchiveSearchConsts.FACETS_COMPUTE_RULES_AU_NUMBER;
import static fr.gouv.vitamui.commons.api.utils.ArchiveSearchConsts.FACETS_COUNT_BY_NODE;
import static fr.gouv.vitamui.commons.api.utils.ArchiveSearchConsts.FACET_SIZE_MULTIPLIER;
import static fr.gouv.vitamui.commons.api.utils.ArchiveSearchConsts.FILING_UNIT_TYPE;
import static fr.gouv.vitamui.commons.api.utils.ArchiveSearchConsts.HOLDING_UNIT_TYPE;
import static fr.gouv.vitamui.commons.api.utils.ArchiveSearchConsts.ID;
Expand Down Expand Up @@ -122,12 +121,12 @@ public final class MetadataSearchCriteriaUtils {

private MetadataSearchCriteriaUtils() {}

public static SelectMultiQuery createDslQueryWithFacets(SearchCriteriaDto searchQuery)
public static SelectMultiQuery createDslQueryWithFacets(SearchCriteriaDto searchQuery, Integer facetsSize)
throws VitamClientException, InvalidCreateOperationException {
fillWaitingToComputeCriteria(searchQuery);

SelectMultiQuery selectMultiQuery = mapRequestToSelectMultiQuery(searchQuery);
addPositionsNodesFacet(searchQuery, selectMultiQuery);
selectMultiQuery.addFacets(FacetHelper.terms(FACETS_COUNT_BY_NODE, ALL_UNIT_UPS, facetsSize, FacetOrder.ASC));

if (searchQuery.isComputeFacets()) {
selectMultiQuery.addFacets(
Expand Down Expand Up @@ -1700,19 +1699,6 @@ public static boolean isADateToReplace(SearchCriteriaEltDto searchCriteria) {
);
}

private static void addPositionsNodesFacet(SearchCriteriaDto searchQuery, SelectMultiQuery selectMultiQuery)
throws InvalidCreateOperationException {
List<String> nodesCriteriaList = searchQuery.extractNodesCriteria();
selectMultiQuery.addFacets(
FacetHelper.terms(
FACETS_COUNT_BY_NODE,
ALL_UNIT_UPS,
(nodesCriteriaList.size() + 1) * FACET_SIZE_MULTIPLIER,
FacetOrder.ASC
)
);
}

public static String cleanString(String initialValue) {
if (initialValue == null) return null;
return initialValue
Expand Down
8 changes: 5 additions & 3 deletions deployment/environments/group_vars/all/vitamui_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ vitamui:
ui_collect:
vitamui_component: ui-collect
port_service: 8010
# offline_services: # Disables online search engines in collect
# - agencies
# - archive-unit-profiles
# offline_services: # Disables online search engines in collect
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi ajouter de l'indentation ici ?

# - agencies
# - archive-unit-profiles
ui_pastis:
vitamui_component: ui-pastis
port_service: 9015
Expand Down Expand Up @@ -143,12 +143,14 @@ vitamui:
vitamui_component: archive-search
port_service: 8109
port_admin: 7109
tree_nodes_search_facets_size: 1000

collect:
host: "vitamui-collect.service.{{ consul_domain }}"
vitamui_component: collect
port_service: 8110
port_admin: 7110
tree_nodes_search_facets_size: 1000

pastis:
host: "vitamui-pastis.service.{{ consul_domain }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ opentracing:

ontologies_file_path: {{ vitamui_folder_data }}/external_ontology_fields.json

tree-nodes-search-facets-size: {{ vitamui_struct.tree_nodes_search_facets_size}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mettre un default sur les templates.


logging:
config: {{ vitamui_folder_conf }}/logback.xml
level:
Expand Down
2 changes: 2 additions & 0 deletions deployment/roles/vitamui/templates/collect/application.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ collect:

ontologies_file_path: {{ vitamui_folder_data }}/external_ontology_fields.json

tree-nodes-search-facets-size: {{ vitamui_struct.tree_nodes_search_facets_size}}

{% if opentracing.jaeger.enabled | default(false) | bool %}
opentracing:
jaeger:
Expand Down
Loading