Smart Search MVC System.FormatException Error

Colin Stearns asked on April 21, 2016 20:25

I'm trying to get results from a call to SearchService.Search following the example from Kentico's 9 Documentation link text. The issue I'm having is that when the results are returned I get a server error saying "System.FormatException: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)". I can tell I'm getting the correct results as numberOfResults is 2 when I hover over it in visual studios. I do not know why the full model can not be built out with the returned results. Here is the code

public static readonly string[] searchIndexes = new string[] { "ProductSearch" }; private readonly SearchService mService = new SearchService(searchIndexes, "en-US", SiteContext.CurrentSite.SiteName, false);

private const int PAGE_SIZE = 10; public static readonly string[] searchIndexes = new string[] { "ProductSearch" }; private readonly SearchService mService = new SearchService(searchIndexes, "en-US", SiteContext.CurrentSite.SiteName, false); private const int PAGE_SIZE = 10; SearchIndexInfo index = SearchIndexInfoProvider.GetSearchIndexInfo("ProductSearch");

    // GET: Products
    [ValidateInput(false)]
    public ActionResult Index(string searchText)
    {
        var searchModel = new SearchResultViewModel();
        //var resusls = mService.Search(searchText, 0, 30, out numberOfResults);
        var model = new SearchResultsModel()
        {
            Items = mService.Search(
                searchText,
                page: 0,
                pageSize: PAGE_SIZE,
                numberOfResults: out numberOfResults),
            Query = searchText,
            ItemCount = numberOfResults
        };
        searchModel.SearchResult = model;
        return View(searchModel);
    }

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