Skip to content

Commit

Permalink
[NAE-1909] Elasticsearch index per URI node
Browse files Browse the repository at this point in the history
- implement
  • Loading branch information
machacjozef committed Aug 2, 2023
1 parent cecc385 commit 65ddc59
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.Optional;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -47,7 +48,7 @@ public static IndexAwareElasticSearchRequest ofIndexes(List<String> indexNames)
}

public static IndexAwareElasticSearchRequest ofMenuItems(List<String> menuItemIds) {
return new IndexAwareElasticSearchRequest(Collections.unmodifiableList(menuItemIds), null);
return new IndexAwareElasticSearchRequest(Collections.unmodifiableList(Optional.ofNullable(menuItemIds).orElse(Collections.emptyList())), null);
}

public boolean doQueryAll() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ protected List<String> getIndexes(IndexAwareElasticSearchRequest request) {
List<String> result = new ArrayList<>();
if (request.getIndexNames() != null && !request.getIndexNames().isEmpty()) {
if (request.doQueryAll()) {
result.addAll(indexService.getAllDynamicIndexes());
result.addAll(indexService.getAllIndexes());
} else {
result.addAll(request.getIndexNames());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public PagedModel<CaseResource> search2(@QuerydslPredicate(root = Case.class) Pr
public PagedModel<CaseResource> searchByIndex(@RequestBody IndexAwareApiCaseSearchRequest searchBody, @RequestParam(defaultValue = "OR") MergeFilterOperation operation, Pageable pageable, PagedResourcesAssembler<Case> assembler, Authentication auth, Locale locale) {
LoggedUser user = (LoggedUser) auth.getPrincipal();
IndexAwareElasticSearchRequest elasticRequest;
if (searchBody.getSearchAll()) {
if (searchBody.getSearchAll() || searchBody.getMenuItemIds() == null || searchBody.getMenuItemIds().isEmpty()) {
elasticRequest = IndexAwareElasticSearchRequest.all();
} else {
elasticRequest = IndexAwareElasticSearchRequest.ofMenuItems(searchBody.getMenuItemIds());
Expand Down

0 comments on commit 65ddc59

Please sign in to comment.