Bulk sync relationships for global search (IBM Knowledge Catalog)

To start using the global search indexed data for relationships, you need to run the bulk sync utility after the upgrade.

If you are upgrading to 5.1.0 or later, you must complete both of the following tasks to be able to search for relationships using the global search bar and to sort by item name in the relationships table.

Prerequisites

Required roles

To complete this task, you must have one of the following roles:

  • Cluster administrator
  • Instance administrator

Clean up relationships metadata in global search

Run this procedure to clean up relationships metadata after you upgrade to 5.1.0 or later.

Do not run this procedure with any other payload than recommended by IBM. Once the metadata is cleaned there is no way to restore.

  1. From your local environment, oc login as admin to the cluster.

  2. Port forward elastic search pod to a port:

    oc port-forward elasticsea-0ac3-ib-6fb9-es-server-esnodes-0 19200
    
  3. Run the search call to verify:

    curl  -X GET \
    'http://localhost:19200/wkc-ALIAS/_search' \
    --header 'Accept: */*' \
    --header 'Content-Type: application/json' \
    --data-raw '{"query":{"term": {"metadata.artifact_type": "relationship"}}}'
    
  4. Delete the relationship documents:

    curl  -X POST \
    'http://localhost:19200/wkc-ALIAS/_delete_by_query' \
    --header 'Accept: */*' \
    --header 'Content-Type: application/json' \
    --data-raw '{"query":{"term": {"metadata.artifact_type": "relationship"}}}'
    
  5. Proceed to the bulk sync procedure for relationships.

Bulk sync relationships

Run a bulk sync for the global search index after upgrade. Ensure you are logged into the cluster as an administrator or through the command line.

  1. Copy the following script into your local environment as cpd_gs_sync.sh:

     #!/bin/bash
    
     function prompt_for_namespace(){
         read -p "Please provide namespace in which WKC is installed: " NAMESPACE
         echo "Job will be deployed into \"$NAMESPACE\" namespace"
     }
    
     function all_container_confirmation(){
         read -p "ARE YOU SURE YOU WANT TO CONTINUE? THIS WILL AFFECT ALL CONTAINERS, AND MAY TAKE A LONG TIME. TYPE
         \"YES\" TO PROCEED: " PROCESS_ALL
         if [[ $PROCESS_ALL != "YES" ]]; then
             echo "Job run cancelled."
             exit 0
         fi
         echo "All containers will be processed"
     }
    
     function prompt_for_list_of_catalogs(){
         read -p "Please provide the list of containers to synchronize separated by commas, empty list indicates
         processing all containers(catalog/project/space): " CATALOGS_STRING
         IFS=', ' read -r -a CATALOGS <<< "$CATALOGS_STRING"
         if [[ $CATALOGS_STRING == "" ]]; then
             all_container_confirmation
         else
             echo "Following containers will be processed: "
             for index in "${!CATALOGS[@]}"
             do
                 echo "$index - ${CATALOGS[index]}"
             done
         fi
     }
    
     function construct_db_list_string(){
         DB_STRING="["
         first=true
         for index in "${!CATALOGS[@]}"
         do
             if [ $first == false ]; then
                 DB_STRING+=","
             fi
             first=false
             DB_STRING+="\"${CATALOGS[index]}\""
         done
         DB_STRING+="]"
     }
    
     function patch_cronjob(){
         oc set env -n $NAMESPACE cronjob/wkc-search-relationships-cronjob dbs_to_sync=$DB_STRING
     }
    
     function spawn_job(){
         oc delete job -n $NAMESPACE wkc-search-relationships-job
         oc create job -n $NAMESPACE --from=cronjob/wkc-search-relationships-cronjob wkc-search-relationships-job
     }
    
     function restore_cronjob(){
         oc set env -n $NAMESPACE cronjob/wkc-search-relationships-cronjob dbs_to_sync=[]
     }
    
     prompt_for_namespace
     prompt_for_list_of_catalogs
     construct_db_list_string
     patch_cronjob
     spawn_job
     restore_cronjob
    
  2. Execute the code from step 1, using the following command:

    chmod +x ./cpd_gs_sync.sh
    
    
  3. Execute the job, using the following command:

    ./cpd_gs_sync.sh
    

    Follow the prompts in the terminal to customize the job as required.

    Note: If the list of containers is empty, all of the catalogs, projects, and workspaces will be resynched.
  4. Run the following command to check the status of the job (wkc-search-relationships-job):

    oc get jobs -n ${CPD_INSTANCE_PROJECT} -w | grep relationships
    

    Once the job is complete, the status will display:

    wkc-search-relationships-job                      1/1           3m52s      20m
    
  5. When the job status is complete, run the following patch command to enable the use of global search relationships:

    oc patch ccs ccs-cr -n ${CPD_INSTANCE_PROJECT} --type=merge --patch='{"spec":   {"portal_catalog_is_global_search_relationships_enabled": "true"}}'
    
  6. To ensure that the portal-catalog pod has been restarted:

    1. Get the pod name:

      oc get pods -n ${CPD_INSTANCE_PROJECT} -w | grep portal-catalog
      
    2. Delete the pod. Replace <pod-name> with the name of the pod from step a.

      oc delete pod <pod-name> -n ${CPD_INSTANCE_PROJECT}
      

Parent topic: Administering IBM Knowledge Catalog