1

I'm having some issues with using LabelMatchInformation to search for terms in the managed metadata service. I'm searching for my terms like this:

var labelMatchInfo = new LabelMatchInformation(clientContext)
{
    TermLabel = searchTerm,
    DefaultLabelOnly = true,
    StringMatchOption = StringMatchOption.StartsWith
    ResultCollectionSize = maxMatchCount,
    TrimUnavailable = true
};

var termResults = termStore.GetTerms(labelMatchInfo);

Where searchTerm is what I'm searching for.

Documentation at https://msdn.microsoft.com/en-us/library/hh626704%28v=office.12%29.aspx (I've highlighted the relevant section with bold):

The LabelMatchInformation.TermLabel (section 3.1.5.30.1.1.6) cannot be null or empty, and MUST NOT exceed 255 characters in length. It also cannot contain any of the following illegal characters: ; " < > | & tab The search is case-insensitive, and will match either the entire label or only check that it starts with the specified string depending on the value of the LabelMatchInformation.StringMatchOption (section 3.1.5.30.1.1.5) parameter. If the LabelMatchInformation.StringMatchOption is not set, it defaults to exact match.

This clearly states that the search should be case-insensitive; however, I've found that to not be the case. An example: searching for lever returns the terms leveranse personkunde, levert til kunde, leverandør. However, a search for Lever (capital L), returns Leveranse Bedrift. The expected result would be that either search term would return the full result set including all of leveranse personkunde, levert til kunde, leverandør and Leveranse Bedrift.

What is going on here? Is the documentation wrong, or have I misinterpreted how this is supposed to work? I'm a bit confused by the function description at the top of the documentation above. It reads:

Gets a collection of all Term (section 3.1.5.16) objects from the current TermSet (section 3.1.5.20) object based on the label criteria provided.

However, I'm calling the GetTerms function on a TermStore object, so where does the "current TermSet" come from? All of the lowercase terms are in the default Keywords term set, while the uppercase one is in a manually created term set. However, both term sets reside in the same term store. Does the GetTerms function just look for the first term set containing a match, and then ignore the rest?

UPDATE:

I've now established that it completely ignores the StringMatchOption if set to ExactMatch too, and always makes the call as if it was set to StringMatchOption.StartsWith. Am I looking at outdated/wrong documentation here? Or is it just the documentation itself that is incorrect?

0

The issue in this case was a version mismatch between the referenced Microsoft.SharePoint.Client.dll and the SharePoint Server version. The DLL file was the RTM version (15.0.4420.x) while the server was on Service Pack 1 (15.0.4569.1000). After updating the reference, it worked as expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.