3

I have read as much as I can about smart groups but I am having problems that I am not able to solve. I have a smart group which shows the same SQL as an Advanced Search but they produce different results.

The Smart Group displays the criteria and the number of items selected being 25

The same query using a separate Advanced Search displays 31 items

If I refresh the smart group cache I get the same result.

1

Some clarification about 'getting smart groups to refresh'

I assume you are using the button 'update smartgroup counts' from the Manage groups screen. This could perhaps be better called 'calculate missing smartgroup counts' (although that wouldn't fit on the button.....) - that button causes the count to be calculated for all groups that the cache has not been built for.

Groups are only recalculated if they have aged out - by default the smart group timeout is 5 minutes. Pretty much whenever you save a contact it attempts to delete the cache for any smart groups that are more than those 5 minutes old (you can set the cache to less than 5 minutes or 0 for more caching). It will then re-fill the cache for that group next time you access it.

If you barely ever edit contacts I guess the cache might not get cleared as often as it 'should' - you can schedule a job (Job.group_cache_flush) to run however often you want - if you do this it makes sense to set the setting 'smart_group_cache_refresh_mode' to 'deterministic' to stop it from also clearing on contact edit (note that this is often good to do for performance reasons)

0

I think you have a participant/event item in there - so that means some of your Contacts would have participated in more than one event!

Try: Search Builder - it only returns the Contacts (unique)

  • 1
    I have rebuilt the filter using Search Builder and correctly obtain a dataset of 31 contacts. I have created a Smart Group from this dataset. If I now add a contact with the criteria to satisfy the smart group and view the smart group, the new contact appears in the smart group. However if I now change the criteria on the newly created contact so that it does not comply with the smart group it remains in the smart group. If I run the job Rebuild Smart Group Cache the smart group continues to contain the contact whose criteria no longer comply with the smart group. – Martin Fuggle Jul 7 '16 at 3:19
  • I'm having a similar issue. Are you found some solution? – Francesc Bassas i Bullich Oct 14 '16 at 21:27
  • I can reproduce similar problems whereby a smartgroup that is based on a date range is not refreshed when another contact should meet the date criteria – Dave T Oct 18 '16 at 2:54
  • 2
    @MartinFuggle I have tested this on 4.7.12 and found that Rebuild Smart Group Cache might not remove the contact whose criteria no longer comply with the smart group but Administer > System Settings > Cleanup Caches and Update Paths > Cleanup Caches does. So it seems to be a cache issue rather than a problem with than the underlying smart group functionalility. – JoAnne Oct 28 '16 at 0:54
  • That last comment deserves to be an answer imo – petednz - fuzion Apr 2 '17 at 19:34
0

This answer was a comment by Joanne which I think deserved to be an answer

I have tested this on 4.7.12 and found that Rebuild Smart Group Cache might not remove the contact whose criteria no longer comply with the smart group but Administer > System Settings > Cleanup Caches and Update Paths > Cleanup Caches does. So it seems to be a cache issue rather than a problem with the underlying smart group functionality

  • I have the same problem (tested on 5.8.2 and 5.9.1) : when I select Individuals via Advanced Search, I get 19 results, while, when I modify an existing Smart Group towards the same criteria, I get only 9 in the Search, thus in the modified Smart Group. This is really bothering, because I have embedded smart Groups. – Jacques-Marie Moranne Jan 27 at 11:47
  • I don't think it is just a cache issue : the problem occurs at the Search phase (before updating the Smart Group) – Jacques-Marie Moranne Jan 27 at 11:58
0

I think there is a bug : I could reproduce it on the demo site :

  • Create a group : TEST
  • Advance search Individuals whose name contains "Adam" > You get 12 instances > Create smart group G1 under TEST
  • Advance search Individuals whose name contains "ck" > You get 8 instances > Create smart group G2 under TEST
  • Advance search Individuals whose name contains "y" > You get 52 instances > Create smart group G3 under TEST
  • Advance search Groups G1, G2, G3 > You get 70 (you could expect 72, but there are some common results) > Create smart group "Total" under TEST

Now,

  • open G1 and modify search criteria : "Ad" instead of "Adam" > you get 18 instances (instead of 12), thus 6 more > Update the smart group
  • Open group "Total" > you get 77 instead of 70, thus 7 more : why 7 and not 6 ?

Now again,

  • open G1 again and modify search criteria : "d" instead of "Ad" > You get 71 instances (instead of 18, thus a lot more) > Update the smart Group
  • Open group "Total" > you still get 77 (while it should contain much more than that)
  • Open "test" > you get 104 while there is no reason why it should be different from "Total" result

I have just openned an issue : https://lab.civicrm.org/dev/core/issues/694

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.