SearchHelper.Search DataSet always returns NULL

Theodore Cromwell asked on November 17, 2016 20:51

I have been smashing my head over this. In the admin area, the test search works on the Index, but I get NULL everytime I make a request through the API.

private static DataSet ExecuteSearch(string searchTerm)
{
    SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo("PPG.CEMProductSearch");

    SearchParameters parameters = new SearchParameters
    {
        SearchFor = searchTerm,
        SearchSort = null,
        Path = "/%",
        ClassNames = null,
        DefaultCulture = null,
        CurrentCulture = "##ALL##",
        CombineWithDefaultCulture = false,
        CheckPermissions = false,
        SearchInAttachments = false,
        User = MembershipContext.AuthenticatedUser,
        SearchIndexes = sii.IndexName,
        DisplayResults = 100,
        NumberOfProcessedResults = 100,
        NumberOfResults = 100,
        AttachmentWhere = null,
        AttachmentOrderBy = null,
    };
    DataSet sr = SearchHelper.Search(parameters);
    return sr;
}

Recent Answers


Theodore Cromwell answered on November 17, 2016 20:57

When I inspect the sii (SearchIndexInfo), it lists the IndexFileSize as 0.

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on November 17, 2016 21:31

Hi,
What is the entire code you are using? What is the index type? I am asking since the ClassNames property in your code is set to null. The same for culture. Is it user or custom table index? You can also take inspiration from the Search() method of the SearchResults control: \CMS\CMSModules\SmartSearch\Controls\SearchResults.ascx.cs

0 votesVote for this answer Mark as a Correct answer

Anton Grekhovodov answered on November 18, 2016 05:10 (last edited on November 18, 2016 05:54)

Hi Theodore,

What expression do you have in searchTerm?

0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on November 18, 2016 11:28

Open your search index in Kentico admin, go to search preview tab and make sure it returns some results there. This seems to be index issue, not API. Also you may check index size and indexed items count on index general tab.

0 votesVote for this answer Mark as a Correct answer

Theodore Cromwell answered on November 18, 2016 15:48

Are there any local files that I need to be looking for in the solution. This project is Kentico 9 and setup as a separate Admin and MVC projects. I see a SmartSearch folder in the Admin project (App_Data/CMSModules/SmartSearch), but not in the MVC project which is where the API call is made.

In the MVC solution, it appears that the Index exists, but it is empty.

0 votesVote for this answer Mark as a Correct answer

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