Searching by XmlConfigId using IndexSearch API does not work after upgrade to v8.5

  • Updated

If prior to version 8.5, you were using Ektron's Index Search API to search by the XmlConfigId metadata, this code will not work after upgrading your site to CMS400.Net Version 8.5. With CMS400.Net Version 8.5, Ektron uses Microsoft Search Server asthe search platform. The existing search code will have to be converted to its corresponding Search Server equivalent using the new Framework Search APIs for search to work correctly. For backward compatibility, the old Search API code will work aftersome modification (shown in the example below), but Ektron recommends using the new Framework Search APIs for writing your search code.

Following code does not yield results after upgrading to CMS400.Net version 8.5 (throws an exception - Your query is malformed. Please rephrase your query):

                    Dim requestData As IndexSearchRequestData = New IndexSearchRequestData()
                    requestData.FolderID = 0
                    requestData.XmlConfigID = 31
                    Dim index1 As IndexSearchFieldData = New IndexSearchFieldData()
                    index1.XPath = "/root/xmlconfigID"
                    index1.DataType = XMLDataType.Number
                    index1.SearchType = XMLSearchRangeType.EqualTo
                    index1.Value = 31

                    requestData.IndexSearchFieldList = New IndexSearchFieldData() {index1}
Dim resultCount As Integer
                    Dim result() As SearchResponseData = search.Search(requestData, HttpContext.Current, resultCount)

XmlConfigId is now a managed property in the Search Server for your CMS400.Net Version 8.5 site. Searching by this property can be achieved by querying your CMS site content source using a managed property query syntax. As mentioned above, the old Search API code will work after some modification (shown in the example below) but Ektron recommends migrating your code to use the new Framework Search APIs designed for effectively searching the content source of your CMS400.Net site. Both solutions are illustrated below.

Solution 1 (using new Framework Search API)

        KeywordSearchCriteria criteria = new KeywordSearchCriteria();
        criteria.IncludeSuggestedResults = false;
        criteria.ImplicitAnd = true;
        criteria.ReturnProperties = new HashSet(PropertyMappings.ContentSearchProperties);
        criteria.PagingInfo = new PagingInfo(10);
        criteria.OrderBy = new List() { new OrderData(SearchContentProperty.Rank, OrderDirection.Descending) };
        PropertyExpression propertyExpression = SearchContentProperty.XmlConfigId;
        Expression expression = new EqualsExpression(propertyExpression, 31);
        expression &= SearchContentProperty.Language.EqualTo(1033);
        criteria.ExpressionTree = expression;

        ISearchManager manager = ObjectFactory.GetSearchManager();
        Ektron.Cms.Search.SearchResponseData responseData = manager.Search(criteria);