Goal:
Some customers may need to migrate business rules between environments. When doing so they may need to first remove all the existing rules for the collection they are migrating to. For example, a customer may want to migrate all business rules from PROD to DEV for testing or development -- and may need to delete all the rules in DEV prior to import.
Note: In order to delete a single rule by ID, see Option 3 below.
Environment:
Fusion 5.x
Guide:
Option 1: Delete only the business rules
Create a file called deleteAllRules.json with the following contents:
{"delete":{"query":"doc_type:rule"}}
Delete the rules using the commands below
# Delete business rules in the published rewrite rules collection -- POST with the query payload (delete where doc_type is rule)
curl -u $USER:$PASS -H 'Content-type: application/json' "http://$FUSION:$PORT/api/solr/$PUBLISHED_COLLECTION/update?commit=true" -X POST -d @deleteAllRules.json
# Delete business rules in the staging rewrite rules collection -- POST with the query payload (delete where doc_type is rule)
curl -u $USER:$PASS -H 'Content-type: application/json' "http://$FUSION:$PORT/api/solr/$STAGING_COLLECTION/update?commit=true" -X POST -d @deleteAllRules.json
Option 2: Delete all the business rules AND all the rewrites and everything else that may be in the collections
Create a file called deleteAll.json with the following contents:
{"delete":{"query":"*:*"}}
Delete the rules using the commands below
# Delete business rules in the published rewrite rules collection -- POST with the query payload (delete where doc_type is rule)
curl -u $USER:$PASS -H 'Content-type: application/json' "http://$FUSION:$PORT/api/solr/$PUBLISHED_COLLECTION/update?commit=true" -X POST -d @deleteAll.json
# Delete business rules in the staging rewrite rules collection -- POST with the query payload (delete where doc_type is rule)
curl -u $USER:$PASS -H 'Content-type: application/json' "http://$FUSION:$PORT/api/solr/$STAGING_COLLECTION/update?commit=true" -X POST -d @deleteAll.json
Option 3: Delete a specific business rule by ID
# First get a list of all the business rules. This will be used for find the ID of the rule we want to delete
curl -X 'GET' -u $USER:$PASS 'http://$FUSION:$PORT/api/apps/$APP/query-rewrite/instances' -H 'accept: application/json' > my-exported-rules.json
# Using the ID of a rule from the output of the previous command, delete the rule
curl -u $USER:$PASS -XPUT -H "Content-type:application/json" 'http://$FUSION:$PORT/api/apps/$APP/query-rewrite/instances' -d '{"delete": [ "$ID" ]}'
# Now publish all your changes for the rewrite rules
curl -u $USER:$PASS -XPUT -H "Content-type:application/json" 'http://$FUSION:$PORT/api/apps/$APP/query-rewrite/publish'
Comments
0 comments
Article is closed for comments.