Goal
Migrate business rules between Fusion 4.x environments and restrict them to specific query pipelines using tags.
Environment
Fusion 4.2.6
Solr 7.7.3
Applies to self-hosted environments only
Guide
Export and import all business rules using Solr backup/restore
Use this method when you want to move all business rules between environments. It leverages Solr's replication API to back up and restore the query rewrite collections.
Replace all placeholders with values specific to your environment.
# Create backup directories on the source host
mkdir /tmp/query_rewrite_staging
mkdir /tmp/query_rewrite
# Backup the staging collection from the source environment
curl -u $USERNAME:$PASSWORD "http://$SOLR_SOURCE_HOST:8983/solr/$APP_query_rewrite_staging/replication?command=backup&location=/tmp/query_rewrite_staging"
# Backup the published collection from the source environment
curl -u $USERNAME:$PASSWORD "http://$SOLR_SOURCE_HOST:8983/solr/$APP_query_rewrite/replication?command=backup&location=/tmp/query_rewrite"
# Restore the staging collection on the destination environment
curl -u $USERNAME:$PASSWORD "http://$SOLR_DESTINATION_HOST:8983/solr/$APP_query_rewrite_staging/replication?command=restore&location=/tmp/query_rewrite_staging"
# Restore the published collection on the destination environment
curl -u $USERNAME:$PASSWORD "http://$SOLR_DESTINATION_HOST:8983/solr/$APP_query_rewrite/replication?command=restore&location=/tmp/query_rewrite"This method will synchronize all rule types (e.g., set_params, block, etc.) between the two environments. Ensure the application ($APP) exists in both environments before performing this operation.
Import a single rule using Fusion API
Use this method when selectively migrating individual rules. After inserting the rule via API, it must also be published to appear in the UI and be used in queries.
Create a rule (POST)
curl -u admin:$PASSWORD -H 'Content-type: application/json' -X PUT \
http://$FUSION_HOST:8764/api/apps/$APP/query-rewrite/instances/$RULE_ID/publishIf this step is skipped, the rule will not appear in the UI or be used in query rewriting.
Note: If your environment blocks PUT operations via curl, consider testing from a different client or scripting language (e.g., Python or PowerShell) to determine if the issue is environmental
Restrict business rules to specific query pipelines using tags
Fusion 4.x does not support scoping business rules directly to query pipelines. However, you can simulate this behavior by using tags.
Steps to scope rules using tags
Add a tag to the rule in the GENERAL section of the rule editor (or include it in the rule definition JSON using the
tagsfield).Ensure your query includes the matching
tagparameter:?tags=my-custom-tag
Only queries with that tag will match the rule. This allows you to simulate pipeline-specific rule triggering.