Here at Orckestra, Commerce Server is an important part of our offering. Evidently, any new release of Commerce Server is analysed and validated against any of our solutions. In this process, We have discovered a very important bug in the new Commerce Server 2009.
Most of our solutions depend on the Free-Text search capabilities of Commerce Server. In this optic, I tried creating a simple search using the API:
var query = new CommerceQuery<CatalogEntity, CommerceCatalogFullTextSearchBuilder>();
query.SearchCriteria.Catalogs.Add("My_Catalog");
query.SearchCriteria.FirstItemIndex = 0;
query.SearchCriteria.FullTextSearchType = CommerceFullTextSearchType.FreeText;
query.SearchCriteria.NumberOfItemsToReturn = 500;
query.SearchCriteria.Phrase =”My Criteria”;
query.SearchCriteria.ReturnTotalItemCount = true;
query.SearchCriteria.WhereClause = "[Active] = 1";
As it turns out I was constantly getting an unknown error. Digging through the code and using the SQL Profiler I discovered this line in the [dbo].[ctlg_GetFTSQuery] stored procedure of the catalogue database:
IF @IsVirtualCatalog = 1 or @SQLClause < 1 or (CHARINDEX(N'CONTAINS',@SQLClause) = 0 )
where @SQLClause is defined as an nvarchar(MAX). Well, @SQLClause < 1 is wrong and should then read: LEN(@SQLClause) < 1
So in that regard here is the entire line:
IF @IsVirtualCatalog = 1 or LEN(@SQLClause) < 1 or (CHARINDEX(N'CONTAINS',@SQLClause) = 0 )
Please remember that this bug is in the RTM so I would advise you to fix immediately or any Free-Text search will fail if it contains a where clause. Here is Microsoft’s official response by the way on the Connect site:
Hello David,
Thanks for reporting this. We have identified it is indeed a product defect.
As you already mentioned here, there is a syntax error inside ctlg_GetFTSQuery. Your suggested fix is correct and probably you have already done such modification from your side.
Unfortunately, the same error is also inside RTM release. We are building official fix for this problem. Please contact Microsoft CTS (Commercial Technical Support) for the official fix.
Thanks
Hao
Tags: commerce server, commerce server 2009, bugs