Accessing Search in MVC widget - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Accessing Search in MVC widget

  • Accessing Search in MVC widget
  • I have an MVC widget that shows a list of blog posts and I would like to also search using this widget in place of the built in search widget. A search index has created for blog posts and I followed the code from this article:

    The result is coming back with a hit count of 39 and the IResultSet in the SearchHelper has a collection of items in it. However, when the Helper returns result.SetContentLinks() the result is an empty list.

    Attached are a few screenshots of different points:
    InitialResultObject.png - Before calling SetContentLinks I am able to drill down into the object and see the list and details of each search result.

    CallingSetContentLinks.png - After calling SetContentLinks, drilling down into the Results View of the object it shows an empty result. Sometimes I do get an "Object is not set to an instance of an object" error as well but I don't know what object it is referring to.

    This is the code calling the SearchHelper

    var queryBuilder = ObjectFactory.Resolve<IQueryBuilder>();
    var searchService = ServiceBus.ResolveService<ISearchService>();
    string[] searchFields = "Title", "Content" ;
    var hitCount = 0;

    var result = SearchHelper.Search(searchService, queryBuilder, "searchTerm" , searchFields, "myIndex", null, 0,10, null, null, out hitCount);


    Any thoughts would be appreciated. Thanks!