Trying to understand indexing vs rebuilding cache

CStrategies

Member
I have an addon that adds some new search constraints. The data gets properly indexed, and after rebuilding cache in ACP I can search using those constraints and it works. However, when a new item is posted, it will not appear in the search using those constraints until I rebuild cache again in the ACP.

Is there a hook or other process I am missing in my code that would properly index the data so that it would be searchable immediately without needing to manually rebuild the cache?
 
Solution
Oh, that's because that column is a cache and is fast-updated (which skips entity life-cycle hooks). You would likely need to hook elsewhere and trigger a re-index manually. You could hook the team member entity events.
Hopefully my fumbling will help someone else. I did discover that Entities can have Behaviors in the structure, which can indictate whether an index will receive an update if certain fields are changed. Still not sure how to make sure a particular custom field is recognized by the behavior though...
 
There's usually a checkForUpdates setting in the behavior configuration. You can push new values to the array by extending the entity structure.

So like here for example:

Code:
$structure->behaviors = [
            'XF:Taggable' => ['stateField' => 'resource_state'],
            'XF:Indexable' => [
                'checkForUpdates' => ['title', 'resource_category_id', 'user_id', 'prefix_id', 'tags', 'resource_state']
            ],
I tried adding team_member_user_ids but it still didn't trigger the re-indexing when changing a team member. I ended up manually adding the re-indexing method elsewhere. But it would be cleaner if I could figure out what else I need to do besides adding to the checkForUpdates array...
 
Oh, that's because that column is a cache and is fast-updated (which skips entity life-cycle hooks). You would likely need to hook elsewhere and trigger a re-index manually. You could hook the team member entity events.
 
Solution
Top Bottom