Gravatar for timothy.zavertnik@us.gt.com

Question by timzavertnik, Feb 7, 2019 4:41 PM

Multi-Value Facet - SharePoint Enterprise Keywords - Coveo Cloud v2

I am running into a similar issue that was posted in this question:

https://answers.coveo.com/questions/10666/multi-value-facet-sharepoint-enterprise-keywords-c.html?childToView=19824

An answer was given for the CES 7 version but we are using Coveo Cloud v2. What would be the approach to solve this on that version?

Gravatar for timothy.zavertnik@us.gt.com

Comment by timzavertnik, Feb 7, 2019 7:00 PM

@Jean-François L'Heureux as you requested. Any help or direction that you can provide will be greatly appreciated. Thanks.

2 Replies
Gravatar for timothy.zavertnik@us.gt.com

Answer by timzavertnik, Feb 18, 2019 8:55 PM

For anyone else that runs into this issue, this is how we resolved it. Below is the Python code that goes within the extension to parse the terms. Make sure you run the extension as a post-conversion.

def get_flattened_meta():
    flattened = dict()
    for m in document.get_meta_data():
        for metadata_name, metadata_values in m.values.iteritems():
            flattened[metadata_name.lower()] = metadata_values
    normalized = dict()
    for metadata_name, metadata_values in flattened.iteritems():
        if len(metadata_values) == 1:
            normalized[metadata_name] = metadata_values[0]
        elif len(metadata_values) > 1:
            normalized[metadata_name] = ";".join([str(value) for value in metadata_values])
    return normalized
def clean_multi_value_facet(field_values):
    newFieldValue = ""
    fieldValue = field_values
    fieldValue = fieldValue.replace("#","")
    fieldArray = fieldValue.split(";")
    for i in range(len(fieldArray)):
        if(str(fieldArray[i].isdigit()) == "False"):
            if(i == 0):
                newFieldValue = grab_label(fieldArray[i])
            else:
                newFieldValue = newFieldValue+";"+grab_label(fieldArray[i])
    return newFieldValue
def grab_label(field_value):
    newLabelValue = ""
    labelArray = field_value.split("|")
    for i in range(len(labelArray)):
        if(i==0):
            newLabelValue = labelArray[i]
    return newLabelValue
meta_data = get_flattened_meta()
if "resourcetype" in meta_data:    
    document.add_meta_data({'resourcetype':clean_multi_value_facet(meta_data["resourcetype"])})
Gravatar for jflheureux@coveo.com

Answer by Jean-François L'Heureux, Feb 11, 2019 4:03 PM

With Coveo Cloud V2, pre and post conversion scripts are now called "Indexing pipeline extensions". They are Python scripts instead of jScript, VBScript, or .Net.

You can find the documentation on these pages and subpages:

Administration: https://docs.coveo.com/en/1581/cloud-v2-administrators/manage-extensions

Developer: https://docs.coveo.com/en/156/cloud-v2-developers/coveo-cloud-v2-indexing-pipeline-extensions

It is your role to convert the CES7 VBScript sample script of the referenced question to Python.

Ask a question