You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by js...@apache.org on 2023/03/10 13:17:06 UTC

[unomi] branch master updated: UNOMI-700 : specify indices when doing a refresh (#584)

This is an automated email from the ASF dual-hosted git repository.

jsinovassinnaik pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/unomi.git


The following commit(s) were added to refs/heads/master by this push:
     new 2ac126ac9 UNOMI-700 : specify indices when doing a refresh (#584)
2ac126ac9 is described below

commit 2ac126ac95a0b3e5cc43e097268539f0b66a9f8a
Author: jsinovassin <58...@users.noreply.github.com>
AuthorDate: Fri Mar 10 14:17:00 2023 +0100

    UNOMI-700 : specify indices when doing a refresh (#584)
    
    * UNOMI-700 : specify indices when doing a refresh
---
 .../apache/unomi/services/UserListServiceImpl.java   |  2 +-
 .../test/java/org/apache/unomi/itests/BaseIT.java    |  8 +++++---
 .../test/java/org/apache/unomi/itests/BasicIT.java   |  4 ++--
 .../unomi/itests/ConditionESQueryBuilderIT.java      |  3 ++-
 .../org/apache/unomi/itests/ContextServletIT.java    |  4 +---
 .../unomi/itests/PropertiesUpdateActionIT.java       | 20 ++++++++++----------
 .../java/org/apache/unomi/itests/RuleServiceIT.java  |  8 ++++----
 .../test/java/org/apache/unomi/itests/SegmentIT.java | 18 +++++++++---------
 .../apache/unomi/itests/graphql/GraphQLEventIT.java  |  4 ++--
 .../apache/unomi/itests/graphql/GraphQLListIT.java   |  9 +++++----
 .../unomi/itests/graphql/GraphQLProfileIT.java       |  4 ++--
 .../unomi/itests/graphql/GraphQLSegmentIT.java       |  4 ++--
 .../apache/unomi/itests/graphql/GraphQLSourceIT.java |  5 +++--
 .../apache/unomi/itests/graphql/GraphQLTopicIT.java  |  7 ++++---
 .../apache/unomi/itests/graphql/GraphQLViewIT.java   |  2 +-
 .../unomi/services/impl/AbstractServiceImpl.java     |  2 +-
 .../impl/definitions/DefinitionsServiceImpl.java     |  3 ++-
 .../unomi/services/impl/goals/GoalsServiceImpl.java  |  2 +-
 .../services/impl/profiles/ProfileServiceImpl.java   |  2 +-
 .../unomi/services/impl/rules/RulesServiceImpl.java  |  5 +++--
 .../services/impl/segments/SegmentServiceImpl.java   |  2 +-
 21 files changed, 62 insertions(+), 56 deletions(-)

diff --git a/extensions/lists-extension/services/src/main/java/org/apache/unomi/services/UserListServiceImpl.java b/extensions/lists-extension/services/src/main/java/org/apache/unomi/services/UserListServiceImpl.java
index ba1e74b9a..1c656d1de 100644
--- a/extensions/lists-extension/services/src/main/java/org/apache/unomi/services/UserListServiceImpl.java
+++ b/extensions/lists-extension/services/src/main/java/org/apache/unomi/services/UserListServiceImpl.java
@@ -57,7 +57,7 @@ public class UserListServiceImpl implements UserListService {
 
     public PartialList<Metadata> getListMetadatas(Query query) {
         if (query.isForceRefresh()) {
-            persistenceService.refresh();
+            persistenceService.refreshIndex(UserList.class);
         }
         definitionsService.resolveConditionType(query.getCondition());
         PartialList<UserList> userLists = persistenceService.query(query.getCondition(), query.getSortby(), UserList.class, query.getOffset(), query.getLimit());
diff --git a/itests/src/test/java/org/apache/unomi/itests/BaseIT.java b/itests/src/test/java/org/apache/unomi/itests/BaseIT.java
index 7e4e20cfa..8c166b33c 100644
--- a/itests/src/test/java/org/apache/unomi/itests/BaseIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/BaseIT.java
@@ -211,11 +211,13 @@ public abstract class BaseIT extends KarafTestSupport {
         for (Class<? extends Item> aClass : classes) {
             persistenceService.removeByQuery(condition, aClass);
         }
-        refreshPersistence();
+        refreshPersistence(classes);
     }
 
-    protected void refreshPersistence() throws InterruptedException {
-        persistenceService.refresh();
+    protected void refreshPersistence(final Class<? extends Item>... classes) throws InterruptedException {
+        for (Class<? extends Item> aClass : classes) {
+            persistenceService.refreshIndex(aClass);
+        }
         Thread.sleep(1000);
     }
 
diff --git a/itests/src/test/java/org/apache/unomi/itests/BasicIT.java b/itests/src/test/java/org/apache/unomi/itests/BasicIT.java
index c20a46377..9ca7a76b4 100644
--- a/itests/src/test/java/org/apache/unomi/itests/BasicIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/BasicIT.java
@@ -166,7 +166,7 @@ public class BasicIT extends BaseIT {
                 new File("data/tmp/testLoginEventCondition.json").toURI().toURL(), ConditionType.class);
         definitionsService.setConditionType(conditionType);
 
-        refreshPersistence();
+        refreshPersistence(ConditionType.class);
         Thread.sleep(2000);
         // Add login rule
         Rule rule = CustomObjectMapper.getObjectMapper().readValue(new File("data/tmp/testLogin.json").toURI().toURL(),
@@ -274,7 +274,7 @@ public class BasicIT extends BaseIT {
         checkVisitor2ResponseProperties(requestResponsePageView4.getContextResponse().getProfileProperties());
         Thread.sleep(1000);
 
-        refreshPersistence();
+        refreshPersistence(Profile.class);
 
         // Check both visitor profile at the end by loading them directly
         Profile profileVisitor1 = profileService.load(profileIdVisitor1);
diff --git a/itests/src/test/java/org/apache/unomi/itests/ConditionESQueryBuilderIT.java b/itests/src/test/java/org/apache/unomi/itests/ConditionESQueryBuilderIT.java
index da8dabe03..06e57f484 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ConditionESQueryBuilderIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ConditionESQueryBuilderIT.java
@@ -18,6 +18,7 @@
 package org.apache.unomi.itests;
 
 import org.apache.unomi.api.Item;
+import org.apache.unomi.api.Profile;
 import org.apache.unomi.api.conditions.Condition;
 import org.junit.After;
 import org.junit.Before;
@@ -56,7 +57,7 @@ public class ConditionESQueryBuilderIT extends ConditionEvaluatorIT {
         super.setUp();
         persistenceService.save(item);
         persistenceService.save(emptyItem);
-        persistenceService.refresh();
+        persistenceService.refreshIndex(Profile.class);
     }
 
     @After
diff --git a/itests/src/test/java/org/apache/unomi/itests/ContextServletIT.java b/itests/src/test/java/org/apache/unomi/itests/ContextServletIT.java
index cd40c44b0..10ed9e137 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ContextServletIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ContextServletIT.java
@@ -295,14 +295,12 @@ public class ContextServletIT extends BaseIT {
         request.setEntity(new StringEntity(objectMapper.writeValueAsString(contextRequest), ContentType.APPLICATION_JSON));
         String cookieHeaderValue = TestUtils.executeContextJSONRequest(request, sessionId).getCookieHeaderValue();
 
-        refreshPersistence();
+        refreshPersistence(Event.class);
 
         //Add the context-profile-id cookie to the second event
         request.addHeader("Cookie", cookieHeaderValue);
         ContextResponse response = (TestUtils.executeContextJSONRequest(request, sessionId)).getContextResponse(); //second event
 
-        refreshPersistence();
-
         //Assert
         assertEquals(1, response.getProfileSegments().size());
         assertThat(response.getProfileSegments(), hasItem(SEGMENT_ID));
diff --git a/itests/src/test/java/org/apache/unomi/itests/PropertiesUpdateActionIT.java b/itests/src/test/java/org/apache/unomi/itests/PropertiesUpdateActionIT.java
index 21d3f9290..88c72f647 100644
--- a/itests/src/test/java/org/apache/unomi/itests/PropertiesUpdateActionIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/PropertiesUpdateActionIT.java
@@ -145,7 +145,7 @@ public class PropertiesUpdateActionIT extends BaseIT {
         updateProperties.setProperty(UpdatePropertiesAction.TARGET_TYPE_KEY, "profile");
         eventService.send(updateProperties);
         profileService.save(profile);
-        refreshPersistence();
+        refreshPersistence(Event.class, Profile.class);
 
         profile = keepTrying("Props_to_add should set the prop if it's missing", () -> profileService.load(PROFILE_TEST_ID),
                 loadedProfile -> "New property 1".equals(loadedProfile.getProperty("prop1")), DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
@@ -172,7 +172,7 @@ public class PropertiesUpdateActionIT extends BaseIT {
         updateProperties.setProperty(UpdatePropertiesAction.TARGET_TYPE_KEY, "profile");
         eventService.send(updateProperties);
         profileService.save(profile);
-        refreshPersistence();
+        refreshPersistence(Event.class, Profile.class);
 
         profile = keepTrying("prop1 not updated", () -> profileService.load(PROFILE_TEST_ID),
                 loadedProfile -> "New property 1".equals(loadedProfile.getProperty("prop1")), DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
@@ -193,7 +193,7 @@ public class PropertiesUpdateActionIT extends BaseIT {
         updateProperties.setProperty(UpdatePropertiesAction.TARGET_TYPE_KEY, "profile");
         eventService.send(updateProperties);
         profileService.save(profile);
-        refreshPersistence();
+        refreshPersistence(Event.class, Profile.class);
 
         profile = profileService.load(PROFILE_TEST_ID);
         Assert.assertEquals(2, ((List<String>) profile.getProperty("prop1")).size());
@@ -220,7 +220,7 @@ public class PropertiesUpdateActionIT extends BaseIT {
         updateProperties.setProperty(UpdatePropertiesAction.TARGET_TYPE_KEY, "profile");
         eventService.send(updateProperties);
         profileService.save(profile);
-        refreshPersistence();
+        refreshPersistence(Event.class, Profile.class);
 
         profile = profileService.load(PROFILE_TEST_ID);
         Assert.assertEquals("New property 1", profile.getProperty("prop1"));
@@ -240,7 +240,7 @@ public class PropertiesUpdateActionIT extends BaseIT {
 
         eventService.send(updateProperties);
         profileService.save(profile);
-        refreshPersistence();
+        refreshPersistence(Event.class, Profile.class);
 
         profile = profileService.load(PROFILE_TEST_ID);
         Assert.assertNull(profile.getProperty("prop1bis"));
@@ -263,7 +263,7 @@ public class PropertiesUpdateActionIT extends BaseIT {
         sessionReassigned.setPersistent(false);
         eventService.send(sessionReassigned);
         profileService.save(profile);
-        refreshPersistence();
+        refreshPersistence(Event.class, Profile.class);
         profile = profileService.load(PROFILE_TEST_ID);
         Assert.assertEquals("lastVisit should be updated", eventTimeStamp1, profile.getProperty("lastVisit"));
         Assert.assertEquals("firstVisit should be updated", eventTimeStamp1, profile.getProperty("firstVisit"));
@@ -279,7 +279,7 @@ public class PropertiesUpdateActionIT extends BaseIT {
         sessionReassigned.setPersistent(false);
         eventService.send(sessionReassigned);
         profileService.save(profile);
-        refreshPersistence();
+        refreshPersistence(Event.class, Profile.class);
         profile = profileService.load(PROFILE_TEST_ID);
         Assert.assertEquals("lastVisit should not be updated", eventTimeStamp1, profile.getProperty("lastVisit"));
         Assert.assertEquals("firstVisit should be updated", eventTimeStamp2, profile.getProperty("firstVisit"));
@@ -295,7 +295,7 @@ public class PropertiesUpdateActionIT extends BaseIT {
         sessionReassigned.setPersistent(false);
         eventService.send(sessionReassigned);
         profileService.save(profile);
-        refreshPersistence();
+        refreshPersistence(Event.class, Profile.class);
         profile = profileService.load(PROFILE_TEST_ID);
         Assert.assertEquals("lastVisit should be updated", eventTimeStamp3, profile.getProperty("lastVisit"));
         Assert.assertEquals("firstVisit should not be updated", eventTimeStamp2, profile.getProperty("firstVisit"));
@@ -311,7 +311,7 @@ public class PropertiesUpdateActionIT extends BaseIT {
         sessionReassigned.setPersistent(false);
         eventService.send(sessionReassigned);
         profileService.save(profile);
-        refreshPersistence();
+        refreshPersistence(Event.class, Profile.class);
         profile = profileService.load(PROFILE_TEST_ID);
         Assert.assertEquals("lastVisit should not be updated", eventTimeStamp3, profile.getProperty("lastVisit"));
         Assert.assertEquals("firstVisit should not be updated", eventTimeStamp2, profile.getProperty("firstVisit"));
@@ -337,7 +337,7 @@ public class PropertiesUpdateActionIT extends BaseIT {
             Thread.sleep(4000); // small sleep to create time dif between eventTimeStamp and current system date
             eventService.send(sessionReassigned);
             profileService.save(profile);
-            refreshPersistence();
+            refreshPersistence(Event.class, Profile.class);
             profile = profileService.load(PROFILE_TEST_ID);
             Assert.assertEquals("currentEventTimeStamp should be the exact date of the event timestamp", eventTimeStamp1,
                     profile.getProperty("currentEventTimeStamp"));
diff --git a/itests/src/test/java/org/apache/unomi/itests/RuleServiceIT.java b/itests/src/test/java/org/apache/unomi/itests/RuleServiceIT.java
index 173fbb6a6..e605c039b 100644
--- a/itests/src/test/java/org/apache/unomi/itests/RuleServiceIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/RuleServiceIT.java
@@ -74,7 +74,7 @@ public class RuleServiceIT extends BaseIT {
         assertNull("Expected rule condition to be null", nullRule.getCondition());
         assertEquals("Invalid rule name", TEST_RULE_ID + "_name", nullRule.getMetadata().getName());
         rulesService.removeRule(TEST_RULE_ID);
-        refreshPersistence();
+        refreshPersistence(Rule.class);
         rulesService.refreshRules();
     }
 
@@ -99,7 +99,7 @@ public class RuleServiceIT extends BaseIT {
             String ruleID = ruleIDBase + "_" + i;
             rulesService.removeRule(ruleID);
         }
-        refreshPersistence();
+        refreshPersistence(Rule.class);
         rulesService.refreshRules();
     }
 
@@ -144,7 +144,7 @@ public class RuleServiceIT extends BaseIT {
         rulesService.removeRule(simpleEventTypeRule.getItemId());
         rulesService.removeRule(complexEventTypeRule.getItemId());
         rulesService.removeRule(noEventTypeRule.getItemId());
-        refreshPersistence();
+        refreshPersistence(Rule.class);
         rulesService.refreshRules();
     }
 
@@ -216,7 +216,7 @@ public class RuleServiceIT extends BaseIT {
             ConditionType conditionType = CustomObjectMapper.getObjectMapper().readValue(
                     new File("data/tmp/testClickEventCondition.json").toURI().toURL(), ConditionType.class);
             definitionsService.setConditionType(conditionType);
-            refreshPersistence();
+            refreshPersistence(Rule.class);
             rulesService.refreshRules();
             // Test tracked parameter
             // Add rule that has a trackParameter condition that matches
diff --git a/itests/src/test/java/org/apache/unomi/itests/SegmentIT.java b/itests/src/test/java/org/apache/unomi/itests/SegmentIT.java
index 4dcefebdc..f953b9d1c 100644
--- a/itests/src/test/java/org/apache/unomi/itests/SegmentIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/SegmentIT.java
@@ -535,18 +535,18 @@ public class SegmentIT extends BaseIT {
         scoringElements.add(scoringElement);
         scoring.setElements(scoringElements);
         segmentService.setScoringDefinition(scoring);
-        refreshPersistence();
+        refreshPersistence(Segment.class);
 
         // Send 2 events that match the scoring plan.
         profile = profileService.load("test_profile_id");
         Event testEvent = new Event("test-event-type", null, profile, null, null, profile, timestampEventInRange);
         testEvent.setPersistent(true);
         eventService.send(testEvent);
-        refreshPersistence();
+        refreshPersistence(Event.class);
         // 2nd event
         testEvent = new Event("test-event-type", null, testEvent.getProfile(), null, null, testEvent.getProfile(), timestampEventInRange);
         eventService.send(testEvent);
-        refreshPersistence();
+        refreshPersistence(Event.class, Profile.class);
 
         // insure the profile is engaged;
         try {
@@ -559,7 +559,7 @@ public class SegmentIT extends BaseIT {
             Assert.fail("Unable to read past event because " + e.getMessage());
         }
         profileService.save(testEvent.getProfile());
-        refreshPersistence();
+        refreshPersistence(Profile.class);
         // recalculate event conditions
         segmentService.recalculatePastEventConditions();
         // insure the profile is still engaged after recalculate;
@@ -588,10 +588,10 @@ public class SegmentIT extends BaseIT {
             Assert.fail("Unable to read past event because " + e.getMessage());
         }
         profileService.save(testEvent.getProfile());
-        refreshPersistence();
+        refreshPersistence(Profile.class);
         // now recalculate the past event conditions
         segmentService.recalculatePastEventConditions();
-        persistenceService.refreshIndex(Profile.class, null);
+        refreshPersistence(Profile.class);
         // As 3 events have match, the profile should not be part of the scoring plan.
         keepTrying("Profile should not be part of the scoring anymore", () -> profileService.load("test_profile_id"), updatedProfile -> {
             try {
@@ -629,7 +629,7 @@ public class SegmentIT extends BaseIT {
         scoringElements.add(scoringElement);
         scoring.setElements(scoringElements);
         segmentService.setScoringDefinition(scoring);
-        refreshPersistence();
+        refreshPersistence(Segment.class);
         // Check linkedItems
         List<Rule> rules = persistenceService.getAllItems(Rule.class);
         Rule scoringRule = rules.stream().filter(rule -> rule.getItemId().equals(pastEventCondition.getParameter("generatedPropertyKey")))
@@ -638,7 +638,7 @@ public class SegmentIT extends BaseIT {
 
         // save the scoring once again
         segmentService.setScoringDefinition(scoring);
-        refreshPersistence();
+        refreshPersistence(Segment.class);
         // Check linkedItems
         rules = persistenceService.getAllItems(Rule.class);
         scoringRule = rules.stream().filter(rule -> rule.getItemId().equals(pastEventCondition.getParameter("generatedPropertyKey")))
@@ -647,7 +647,7 @@ public class SegmentIT extends BaseIT {
 
         // Remove scoring
         segmentService.removeSegmentDefinition(scoring.getItemId(), true);
-        refreshPersistence();
+        refreshPersistence(Segment.class);
         // Check linkedItems
         rules = persistenceService.getAllItems(Rule.class);
         boolean isRule = rules.stream().anyMatch(rule -> rule.getItemId().equals(pastEventCondition.getParameter("generatedPropertyKey")));
diff --git a/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLEventIT.java b/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLEventIT.java
index 385a4ff57..329424ded 100644
--- a/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLEventIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLEventIT.java
@@ -60,7 +60,7 @@ public class GraphQLEventIT extends BaseGraphQLIT {
     @Test
     public void testGetEvent() throws Exception {
         final Event event = createEvent(eventID, profile);
-        refreshPersistence();
+        refreshPersistence(Event.class);
 
         try (CloseableHttpResponse response = post("graphql/event/get-event.json")) {
             final ResponseContext context = ResponseContext.parse(response.getEntity());
@@ -77,7 +77,7 @@ public class GraphQLEventIT extends BaseGraphQLIT {
         createEvent("event-2", profile);
         final Profile profile2 = new Profile("profile-2");
         createEvent("event-3", profile2);
-        refreshPersistence();
+        refreshPersistence(Event.class);
 
         try (CloseableHttpResponse response = post("graphql/event/find-events.json")) {
             final ResponseContext context = ResponseContext.parse(response.getEntity());
diff --git a/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLListIT.java b/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLListIT.java
index 712ce9037..ce99b42cb 100644
--- a/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLListIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLListIT.java
@@ -19,6 +19,7 @@ package org.apache.unomi.itests.graphql;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.unomi.api.Profile;
 import org.apache.unomi.api.services.ProfileService;
+import org.apache.unomi.lists.UserList;
 import org.junit.Assert;
 import org.junit.Test;
 import org.ops4j.pax.exam.util.Filter;
@@ -39,7 +40,7 @@ public class GraphQLListIT extends BaseGraphQLIT {
 
             persistedProfile = profileService.save(profile);
 
-            refreshPersistence();
+            refreshPersistence(Profile.class);
 
             keepTrying("Failed waiting for the creation of the profile",
                     () -> profileService.load(profile.getItemId()), Objects::nonNull, 1000, 100);
@@ -52,7 +53,7 @@ public class GraphQLListIT extends BaseGraphQLIT {
                 Assert.assertEquals("testSite", context.getValue("data.cdp.createOrUpdateList.view.name"));
             }
 
-            refreshPersistence();
+            refreshPersistence(UserList.class);
 
             try (CloseableHttpResponse response = post("graphql/list/update-list.json")) {
                 final ResponseContext context = ResponseContext.parse(response.getEntity());
@@ -62,7 +63,7 @@ public class GraphQLListIT extends BaseGraphQLIT {
                 Assert.assertEquals("testSiteUpdated", context.getValue("data.cdp.createOrUpdateList.view.name"));
             }
 
-            refreshPersistence();
+            refreshPersistence(UserList.class);
 
             try (CloseableHttpResponse response = post("graphql/list/get-list.json")) {
                 final ResponseContext context = ResponseContext.parse(response.getEntity());
@@ -78,7 +79,7 @@ public class GraphQLListIT extends BaseGraphQLIT {
                 Assert.assertEquals("testListId", context.getValue("data.cdp.addProfileToList.id"));
             }
 
-            refreshPersistence();
+            refreshPersistence(UserList.class);
 
             Thread.sleep(6000);
 
diff --git a/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLProfileIT.java b/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLProfileIT.java
index 5914ac294..edbd5aeef 100644
--- a/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLProfileIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLProfileIT.java
@@ -75,7 +75,7 @@ public class GraphQLProfileIT extends BaseGraphQLIT {
         final Profile profile = new Profile("FindProfiles_ProfileId1");
         profile.setProperty("firstName", "FindProfiles_Username1");
         profileService.save(profile);
-        refreshPersistence();
+        refreshPersistence(Profile.class);
 
         try (CloseableHttpResponse response = post("graphql/profile/find-profiles.json")) {
             final ResponseContext context = ResponseContext.parse(response.getEntity());
@@ -89,7 +89,7 @@ public class GraphQLProfileIT extends BaseGraphQLIT {
         final Profile profile = new Profile("profileId_deleteAllPersonalDataTest");
         profile.setProperty("firstName", "FirstName");
         profileService.save(profile);
-        refreshPersistence();
+        refreshPersistence(Profile.class);
 
         try (CloseableHttpResponse response = post("graphql/profile/delete-all-personal-data.json")) {
             final ResponseContext context = ResponseContext.parse(response.getEntity());
diff --git a/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLSegmentIT.java b/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLSegmentIT.java
index 2636733c5..9b506a7f3 100644
--- a/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLSegmentIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLSegmentIT.java
@@ -53,7 +53,7 @@ public class GraphQLSegmentIT extends BaseGraphQLIT {
             Assert.assertEquals("http://www.domain.com", context.getValue("data.cdp.createOrUpdateSegment.view.name"));
         }
 
-        refreshPersistence();
+        refreshPersistence(Segment.class);
 
         try (CloseableHttpResponse response = post("graphql/segment/get-segment.json")) {
             final ResponseContext context = ResponseContext.parse(response.getEntity());
@@ -80,7 +80,7 @@ public class GraphQLSegmentIT extends BaseGraphQLIT {
         keepTrying("Failed waiting for the creation of the profile for the \"testCreateSegmentAndApplyToProfile\" test",
                 () -> profileService.load(profile.getItemId()), Objects::nonNull, 1000, 100);
 
-        refreshPersistence();
+        refreshPersistence(Segment.class);
 
         try (CloseableHttpResponse response = post("graphql/segment/create-segment-with-properties-filter.json")) {
             final ResponseContext context = ResponseContext.parse(response.getEntity());
diff --git a/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLSourceIT.java b/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLSourceIT.java
index 985ad267d..ab6dd2067 100644
--- a/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLSourceIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLSourceIT.java
@@ -17,6 +17,7 @@
 package org.apache.unomi.itests.graphql;
 
 import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.unomi.api.Scope;
 import org.apache.unomi.api.services.ScopeService;
 import org.junit.Test;
 import org.ops4j.pax.exam.util.Filter;
@@ -37,7 +38,7 @@ public class GraphQLSourceIT extends BaseGraphQLIT {
             assertNull(context.getValue("data.cdp.createOrUpdateSource.thirdParty"));
         }
 
-        refreshPersistence();
+        refreshPersistence(Scope.class);
 
         try (CloseableHttpResponse response = post("graphql/source/update-source.json")) {
             final ResponseContext context = ResponseContext.parse(response.getEntity());
@@ -46,7 +47,7 @@ public class GraphQLSourceIT extends BaseGraphQLIT {
             assertTrue(context.getValue("data.cdp.createOrUpdateSource.thirdParty"));
         }
 
-        refreshPersistence();
+        refreshPersistence(Scope.class);
 
         try (CloseableHttpResponse response = post("graphql/source/get-sources.json")) {
             final ResponseContext context = ResponseContext.parse(response.getEntity());
diff --git a/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLTopicIT.java b/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLTopicIT.java
index 69c14394a..924dc3bb1 100644
--- a/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLTopicIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLTopicIT.java
@@ -17,6 +17,7 @@
 package org.apache.unomi.itests.graphql;
 
 import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.unomi.api.Topic;
 import org.apache.unomi.api.services.TopicService;
 import org.junit.Assert;
 import org.junit.Test;
@@ -35,7 +36,7 @@ public class GraphQLTopicIT extends BaseGraphQLIT {
             Assert.assertEquals("testTopic", context.getValue("data.cdp.createOrUpdateTopic.id"));
         }
 
-        refreshPersistence();
+        refreshPersistence(Topic.class);
 
         try (CloseableHttpResponse response = post("graphql/topic/update-topic.json")) {
             final ResponseContext context = ResponseContext.parse(response.getEntity());
@@ -45,7 +46,7 @@ public class GraphQLTopicIT extends BaseGraphQLIT {
             Assert.assertEquals("testTopicView", context.getValue("data.cdp.createOrUpdateTopic.view.name"));
         }
 
-        refreshPersistence();
+        refreshPersistence(Topic.class);
 
         try (CloseableHttpResponse response = post("graphql/topic/get-topic.json")) {
             final ResponseContext context = ResponseContext.parse(response.getEntity());
@@ -68,7 +69,7 @@ public class GraphQLTopicIT extends BaseGraphQLIT {
             Assert.assertTrue(context.getValue("data.cdp.deleteTopic"));
         }
 
-        refreshPersistence();
+        refreshPersistence(Topic.class);
 
         try (CloseableHttpResponse response = post("graphql/topic/get-topic.json")) {
             final ResponseContext context = ResponseContext.parse(response.getEntity());
diff --git a/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLViewIT.java b/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLViewIT.java
index 6065b8b29..7ae5c94a3 100644
--- a/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLViewIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLViewIT.java
@@ -49,7 +49,7 @@ public class GraphQLViewIT
         final Topic topic = createTopic();
         final Segment segment = createSegment();
 
-        persistenceService.refresh();
+        persistenceService.refreshIndex(Segment.class);
 
         // test
         try (CloseableHttpResponse response = post( "graphql/views/get-views.json" ))
diff --git a/services/src/main/java/org/apache/unomi/services/impl/AbstractServiceImpl.java b/services/src/main/java/org/apache/unomi/services/impl/AbstractServiceImpl.java
index 1368105f7..afd4f801d 100644
--- a/services/src/main/java/org/apache/unomi/services/impl/AbstractServiceImpl.java
+++ b/services/src/main/java/org/apache/unomi/services/impl/AbstractServiceImpl.java
@@ -55,7 +55,7 @@ public abstract class AbstractServiceImpl {
 
     protected <T extends MetadataItem> PartialList<Metadata> getMetadatas(Query query, Class<T> clazz) {
         if (query.isForceRefresh()) {
-            persistenceService.refresh();
+            persistenceService.refreshIndex(clazz);
         }
         definitionsService.resolveConditionType(query.getCondition());
         PartialList<T> items = persistenceService.query(query.getCondition(), query.getSortby(), clazz, query.getOffset(), query.getLimit());
diff --git a/services/src/main/java/org/apache/unomi/services/impl/definitions/DefinitionsServiceImpl.java b/services/src/main/java/org/apache/unomi/services/impl/definitions/DefinitionsServiceImpl.java
index 52f41e57e..9a098b63e 100644
--- a/services/src/main/java/org/apache/unomi/services/impl/definitions/DefinitionsServiceImpl.java
+++ b/services/src/main/java/org/apache/unomi/services/impl/definitions/DefinitionsServiceImpl.java
@@ -118,7 +118,8 @@ public class DefinitionsServiceImpl implements DefinitionsService, SynchronousBu
     public void reloadTypes(boolean refresh) {
         try {
             if (refresh) {
-                persistenceService.refresh();
+                persistenceService.refreshIndex(ConditionType.class);
+                persistenceService.refreshIndex(ActionType.class);
             }
             loadConditionTypesFromPersistence();
             loadActionTypesFromPersistence();
diff --git a/services/src/main/java/org/apache/unomi/services/impl/goals/GoalsServiceImpl.java b/services/src/main/java/org/apache/unomi/services/impl/goals/GoalsServiceImpl.java
index d7fe34fc0..a5d92232e 100644
--- a/services/src/main/java/org/apache/unomi/services/impl/goals/GoalsServiceImpl.java
+++ b/services/src/main/java/org/apache/unomi/services/impl/goals/GoalsServiceImpl.java
@@ -540,7 +540,7 @@ public class GoalsServiceImpl implements GoalsService, SynchronousBundleListener
     @Override
     public PartialList<CampaignEvent> getEvents(Query query) {
         if(query.isForceRefresh()){
-            persistenceService.refresh();
+            persistenceService.refreshIndex(CampaignEvent.class);
         }
         definitionsService.resolveConditionType(query.getCondition());
         return persistenceService.query(query.getCondition(), query.getSortby(), CampaignEvent.class, query.getOffset(), query.getLimit());
diff --git a/services/src/main/java/org/apache/unomi/services/impl/profiles/ProfileServiceImpl.java b/services/src/main/java/org/apache/unomi/services/impl/profiles/ProfileServiceImpl.java
index 8221f19ff..211e3e3de 100644
--- a/services/src/main/java/org/apache/unomi/services/impl/profiles/ProfileServiceImpl.java
+++ b/services/src/main/java/org/apache/unomi/services/impl/profiles/ProfileServiceImpl.java
@@ -317,7 +317,7 @@ public class ProfileServiceImpl implements ProfileService, SynchronousBundleList
     public void reloadPropertyTypes(boolean refresh) {
         try {
             if (refresh) {
-                persistenceService.refresh();
+                persistenceService.refreshIndex(PropertyType.class);
             }
             loadPropertyTypesFromPersistence();
         } catch (Throwable t) {
diff --git a/services/src/main/java/org/apache/unomi/services/impl/rules/RulesServiceImpl.java b/services/src/main/java/org/apache/unomi/services/impl/rules/RulesServiceImpl.java
index ea6109064..79a1aa638 100644
--- a/services/src/main/java/org/apache/unomi/services/impl/rules/RulesServiceImpl.java
+++ b/services/src/main/java/org/apache/unomi/services/impl/rules/RulesServiceImpl.java
@@ -24,6 +24,7 @@ import org.apache.unomi.api.Metadata;
 import org.apache.unomi.api.PartialList;
 import org.apache.unomi.api.actions.Action;
 import org.apache.unomi.api.conditions.Condition;
+import org.apache.unomi.api.conditions.ConditionType;
 import org.apache.unomi.api.query.Query;
 import org.apache.unomi.api.rules.Rule;
 import org.apache.unomi.api.rules.RuleStatistics;
@@ -364,7 +365,7 @@ public class RulesServiceImpl implements RulesService, EventListenerService, Syn
 
     public PartialList<Metadata> getRuleMetadatas(Query query) {
         if (query.isForceRefresh()) {
-            persistenceService.refresh();
+            persistenceService.refreshIndex(Rule.class);
         }
         definitionsService.resolveConditionType(query.getCondition());
         List<Metadata> descriptions = new LinkedList<>();
@@ -377,7 +378,7 @@ public class RulesServiceImpl implements RulesService, EventListenerService, Syn
 
     public PartialList<Rule> getRuleDetails(Query query) {
         if (query.isForceRefresh()) {
-            persistenceService.refresh();
+            persistenceService.refreshIndex(Rule.class);
         }
         definitionsService.resolveConditionType(query.getCondition());
         PartialList<Rule> rules = persistenceService.query(query.getCondition(), query.getSortby(), Rule.class, query.getOffset(), query.getLimit());
diff --git a/services/src/main/java/org/apache/unomi/services/impl/segments/SegmentServiceImpl.java b/services/src/main/java/org/apache/unomi/services/impl/segments/SegmentServiceImpl.java
index 1b64cbdc5..cb34515c3 100644
--- a/services/src/main/java/org/apache/unomi/services/impl/segments/SegmentServiceImpl.java
+++ b/services/src/main/java/org/apache/unomi/services/impl/segments/SegmentServiceImpl.java
@@ -873,7 +873,7 @@ public class SegmentServiceImpl extends AbstractServiceImpl implements SegmentSe
         }
 
         if (forceRefresh && updatedProfileCount > 0) {
-            persistenceService.refreshIndex(Profile.class, null);
+            persistenceService.refreshIndex(Profile.class);
         }
 
         logger.info("{} profiles updated for past event condition in {}ms", updatedProfileCount, System.currentTimeMillis() - t);