More in this section
Forums / Developing with Sitefinity / Accessing Search in MVC widget

Accessing Search in MVC widget

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
1 posts, 0 answered
  1. Susan
    Susan avatar
    0 posts
    Registered:
    27 Apr 2017
    08 May 2017
    Link to this post

    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: http://knowledgebase.progress.com/articles/Article/How-to-search-programmatically-in-Sitefinity

    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!

    ~Susan

1 posts, 0 answered