How can you get keyword field data when using the .NET API?

The following example can be used for getting keyword field data;

public void getKeywordData(Document document, string keywordFieldname)
            // Get self relation to get access to keyword fields
            Document doc = document.GetDocumentFromSelfRelation();
            DocumentIndexField KWField = doc.Fields.First(f => f.FieldName == keywordFieldname);            
            DocumentIndexFieldKeywords keywords = (DocumentIndexFieldKeywords)KWField.Item;

            foreach (var kw in keywords.Keyword)

For more information on .NET API and code examples, such as the one above, visit our Developer Pages.

KBA is applicable for both Cloud and On-premise Organizations.