API Smart Search: Column 'DocumentModifiedWhen' does not belong to table Table.

Marcel Guldemond asked on January 19, 2016 22:31

With a lot of help from Kentico Support we've finally gotten our MVC app to call the smart search, and now it's throwing this error.

System.ArgumentException

Column 'DocumentModifiedWhen' does not belong to table Table.

at System.Data.DataRow.get_Item(String columnName) at Kentico.Search.SearchService.GetAdditionalData(Object type, Int32 documentNodeId, String& date, Int32& nodeId, String& pageTypeDisplayName, String& pageTypeCodeName) at Kentico.Search.SearchService.GetSearchItems() at Kentico.Search.SearchService.Search(String query, Int32 page, Int32 pageSize, Int32& numberOfResults) at shawmvc.Controllers.SearchController.Index(String searchText, Nullable`1 page) in c:\Projects\Kentico\CMS\ShawMVC\Controllers\SearchController.cs:line 118

To me this looks like a bug in the underlying Kentico SQL stored procedures or generated scripts, because I can't find this column on any of the custom tables or page types that are included in the search indexes that we're searching on.

Any idea of how to find this column, or tell the API call not to include this column would be helpful.

Otherwise I guess I'll have to open a support/bug ticket.

thanks Marcel

EDIT

Here's the relevant code:

      var indexInfos = SearchIndexInfoProvider.GetSearchIndexes();

      string[] indexNames = (from i in indexInfos
            select i.IndexCodeName).ToArray();

      mService = new SearchService( indexNames, 
                            CultureHelper.GetDefaultCultureCode( "SCGDEV" ),   "SCGDEV",true );

         var pageIndex = (page ?? 1) - 1;
        SearchResults model = null;

         model = new SearchResults()
          {
              Items = mService.Search(searchText, pageIndex, PAGE_SIZE, out totalItemsCount),
                                    PageIndex = pageIndex,
                                    PageSize = PAGE_SIZE,
                                    Query = searchText,
                                    TotalItemCount = totalItemsCount
           };

Recent Answers


Joel Dahlin answered on January 19, 2016 23:46

Can you post your code that is throwing an error?

0 votesVote for this answer Mark as a Correct answer

Rui Wang answered on January 20, 2016 16:09 (last edited on January 28, 2016 16:32)

DocumentModifiedWhen column is in the CMS_Document table. So if you are searching pages, you'll need to join the CMS_Document table with the page type table.


Update: Marcel, sorry I didn't realize that you are doing MVC search here. I was just trying to point out that DocumentModifiedWhen is a column in the CMS_Document table. So to get a list of items you would use a join query. Sorry for the confusion.

0 votesVote for this answer Mark as a Correct answer

Marcel Guldemond answered on January 20, 2016 16:53

Thanks for the information Rui. I'll try separating the search indexes out so I can search on custom tables and pages separately to see if I can isolate the issue.

Is there any documentation available on how to join the CMS_Document table to the page type table for the purposes of the search functionality?

thanks, Marcel

0 votesVote for this answer Mark as a Correct answer

Marcel Guldemond answered on January 26, 2016 15:01

I've discovered that if I manually create a CMS.Search.SearchParameters object and then call CMS.Search.SearchHelper.Search(), I get results back.

So it looks like we'll have to skip using the Kentico.Search.SearchService that's used in the MVC example.

0 votesVote for this answer Mark as a Correct answer

Rui Wang answered on January 28, 2016 16:41

Hi Marcel

Thinking from a different direction. Is the error cause by the search index which doesn't contain that data. If you go to a page type or custom table, then click on the "Search fields" tab, you will see a Date Field drop down. Does one of you data type have that field set to "DocumentModifiedWhen"?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.