Commit 4be80597 authored by Michał Kozak's avatar Michał Kozak

rebuild autocomplete index as separate endpoint

parent 1662d572
Pipeline #145829 passed with stage
in 11 minutes and 45 seconds
......@@ -71,6 +71,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
http
.authorizeRequests()
.antMatchers(HttpMethod.PUT, "/api/item-reindex").hasAuthority(Authority.ADMINISTRATOR.name())
.antMatchers(HttpMethod.PUT, "/api/item-autocomplete-rebuild").hasAuthority(Authority.ADMINISTRATOR.name())
.antMatchers(HttpMethod.PUT, "/api/concept-reindex").hasAuthority(Authority.ADMINISTRATOR.name())
.antMatchers("/api/users/**").hasAuthority(Authority.ADMINISTRATOR.name());
http
......
......@@ -18,6 +18,12 @@ public class IndexController {
}
@PutMapping(path = "/item-autocomplete-rebuild")
public void rebuildAutocompleteIndex() {
indexService.rebuildAutocompleteIndex();
}
@PutMapping(path = "/concept-reindex")
public void reindexConcepts() {
indexService.reindexConcepts();
......
......@@ -6,16 +6,11 @@ import eu.sshopencloud.marketplace.model.search.IndexConcept;
import eu.sshopencloud.marketplace.model.search.IndexItem;
import eu.sshopencloud.marketplace.model.vocabularies.PropertyType;
import eu.sshopencloud.marketplace.model.vocabularies.Vocabulary;
import eu.sshopencloud.marketplace.repositories.datasets.DatasetRepository;
import eu.sshopencloud.marketplace.repositories.items.ItemRepository;
import eu.sshopencloud.marketplace.repositories.search.IndexConceptRepository;
import eu.sshopencloud.marketplace.repositories.search.IndexItemRepository;
import eu.sshopencloud.marketplace.repositories.search.SearchItemRepository;
import eu.sshopencloud.marketplace.repositories.tools.ToolRepository;
import eu.sshopencloud.marketplace.repositories.trainings.TrainingMaterialRepository;
import eu.sshopencloud.marketplace.repositories.vocabularies.VocabularyRepository;
import eu.sshopencloud.marketplace.repositories.workflows.StepRepository;
import eu.sshopencloud.marketplace.repositories.workflows.WorkflowRepository;
import eu.sshopencloud.marketplace.services.items.ItemService;
import eu.sshopencloud.marketplace.services.vocabularies.ConceptService;
import eu.sshopencloud.marketplace.services.vocabularies.PropertyTypeService;
......@@ -35,6 +30,7 @@ import java.util.stream.Collectors;
public class IndexService {
private final IndexItemRepository indexItemRepository;
private final SearchItemRepository searchItemRepository;
private final ItemService itemService;
......@@ -50,14 +46,6 @@ public class IndexService {
private final VocabularyRepository vocabularyRepository;
// TEMPORARY
private final ToolRepository toolRepository;
private final TrainingMaterialRepository trainingMaterialRepository;
private final DatasetRepository datasetRepository;
private final WorkflowRepository workflowRepository;
private final StepRepository stepRepository;
public IndexItem indexItem(Item item) {
if (!item.getCategory().equals(ItemCategory.STEP) && itemService.isNewestVersion(item)) {
if (item.getPrevVersion() != null) {
......@@ -83,7 +71,6 @@ public class IndexService {
for (Item item : itemRepository.findAll()) {
indexItem(item);
}
searchItemRepository.rebuildAutocompleteIndex();
}
......@@ -101,6 +88,10 @@ public class IndexService {
}
}
public void rebuildAutocompleteIndex() {
searchItemRepository.rebuildAutocompleteIndex();
}
public void removeConcepts(Vocabulary vocabulary) {
List<IndexConcept> indexConcepts = conceptService.getConcepts(vocabulary.getCode()).stream()
.map(concept -> IndexConverter.covertConcept(concept, vocabulary, Collections.emptyList()))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment